#!/usr/bin/expect set port [lindex $argv 0] #set ip 172.29.118 set ip 192.168.20 spawn rm /public/linboheng/.ssh/known_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