1 set cmd [lindex $argv 0] 2 set pwd [lindex $argv 1] 3 4 #exp_internal 1 5 6 # 1 min timeout 7 #set timeout 60 8 set timeout -1 9 10 eval spawn $cmd 11 12 expect { 13 -nocase "(yes/no)?" { send "yes\r"; exp_continue } 14 -nocase "Password:" { send "$pwd\r" } 15 # Handling ssh keys have already been set up. 16 eof { exit } 17 #timeout { exit 1 } 18 } 19 20 # Wait for eof. 21 expect 22 23 exit 0 24