ssh其他机器的Expect脚本

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
 
扫描二维码关注公众号,回复: 727152 查看本文章

猜你喜欢

转载自jdoc.iteye.com/blog/1189810