1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/usr/bin/expect set command [lindex $argv 0] set passwd [lindex $argv 1] eval spawn "$command" set timeout 60 expect { -re ".*es.*o.*" { exp_send "yes\r" exp_continue } -re ".*sword:" { exp_send "$passwd\r" } } interact