#!/usr/bin/expect set timeout 20 spawn ssh -l root 172.25.254.102 expect "(yes/no)?" send "yes\r" expect "password" send "Asimov\r" expect "#" send "hostname;exit\r" expect eof