#!/usr/bin/expect -f
set ipaddr "192.168.5.4"
set passwd "123qwe"
set timeout 30
spawn ssh root@$ipaddr
expect {
"yes/no" { send "yes
"; exp_continue }
"password: " { send "$passwd
" }
}
expect "*# "
send "ls
"
send "exit
"
expect eof
exit
#!/usr/bin/expect -f
set ipaddr "192.168.5.4"
set passwd "123qwe"
set timeout 30
spawn ssh root@$ipaddr
expect {
"yes/no" { send "yes
"; exp_continue }
"password: " { send "$passwd
" }
}
expect "*# "
send "ls
"
send "exit
"
expect eof
exit