ssh remote host, execute command
#!/usr/bin/expect
spawn ssh user@host
set timeout 10
expect {
timeout {
puts "Connection timed out"
exit 1
}
"yes/no" {
send "yes\r"
exp_continue
}
"password:" {
send "password\r"
exp_continue
}
"user*# " {
send "command\r"
}
}
expect eof