expect ssh

757阅读 0评论2011-04-04 linlan999
分类:

#!/usr/bin/expect -f 
# 设置变量 
set password PASSWORD 
set ipaddr  192.168.2.105
set timeout 5 
# 开启另外一个进程运行ssh登录脚本 
spawn ssh root@$ipaddr 
# 等待输入密码的提示符 
expect "*?assword:*" 
# 使用send命令发送密码 
send "$password\r" 
# 等待超时 
#expect timeout 
interact

上一篇:脚本sudo
下一篇:the virtual machine used for debugging linux kernel hang