- #!/usr/local/bin/expect
- set PASSWD [lindex $argv 1]
- set IP [lindex $argv 0]
- set CMD [lindex $argv 2]
- spawn ssh $IP $CMD
- expect "(yes/no)?" {
- send "yes\r"
- expect "password:"
- send "$PASSWD\r"
- } "password:" {send "$PASSWD\r"} "*host " {exit 1}
- expect eof
时间: 2024-10-20 23:28:38