Debugzhang 2011-10-11
ssh登陆其他机器的Expect脚本
#!/usr/bin/expect -f set user [lindex $argv 0] set ipaddr [lindex $argv 1] set passwd [lindex $argv 2] spawn ssh -l $user $ipaddr expect "password:" send "$passwd\r" interact
或者:
#!/usr/bin/expect -f set user [lindex $argv 0] set ipaddr [lindex $argv 1] set passwd [lindex $argv 2] spawn ssh -l $user $ipaddr expect { "password:" { send "$passwd\r";} } interact
或者:
#!/usr/bin/expect -f set user [lindex $argv 0] set ipaddr [lindex $argv 1] set passwd [lindex $argv 2] spawn ssh -l $user $ipaddr expect "password:" send "$passwd\r" expect eof interact