linux expect, spawn用法小记_IT民工_百度空间 linux expect, spawn用法小记 版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://sysop.blogbus.com/logs/70787883.html 使用expect实现自动登录的脚本,网上有很多,可是都没有一个明白的说明,初学者一般都是照抄.收藏.可是为什么要这么写却不知其然.本文用一个最短的例子说明脚本的原理. 脚本代码如下: ######################
使用VPN,每次都要在Terminal上重复输入命令: ssh -D port user@host 出来密码提示符后,把复杂的密码拷贝下来,然后粘贴到Terminal,敲回车... 终于忍受不了这样的重复了,于是用Shell写一个可以自动登录的脚本: #!/usr/bin/expect -f set port port_no set user user_name set host host_name set password my_password spawn ssh -D $port $use
----安装expectcd /tmp wget http://core.tcl.tk/tcl/zip/release/tcl.zipwget https://jaist.dl.sourceforge.net/project/expect/Expect/5.45.3/expect5.45.3.tar.gz unzip tcl.zip cd ./tcl/unix./configure makemake install cd /tmp tar -xzvf expect5.45.3.tar.gz cd