1set cmd [lindex $argv 0] 2set pwd [lindex $argv 1] 3 4#exp_internal 1 5 6# 1 min timeout 7#set timeout 60 8set timeout -1 9 10eval spawn $cmd 11 12expect { 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. 21expect 22 23exit 0 24