#!/usr/bin/expect set TIMEOUT 20 set SLEEP_DURATION 0.5 set hostname "192.168.1.16" set username "root" set password "123456asj" exec rm -f output.txt set OUTPUT_FILE "output.txt" log_file -a $OUTPUT_FILE proc board {} { global hostname username password spawn telnet $hostname expect "login: " send "$username\r" expect "Password: " send "$password\r" expect "# " send "reboot \r" expect eof } board log_file # exec code output.txt