#!/usr/bin/expect set port [lindex $argv 0] set ip 172.29.118 set hosts /home/daya/.ssh/known_hosts spawn rm $hosts set timeout -1 spawn ssh root@$ip.$port expect { "yes/no" {send "yes\r"} } set timeout 3 expect { "password" {send "root\r"} } expect eof