I am trying to write an expect script to telnet a machine and reboot it. When I run the script manually it works as expected
But when I try to run it autoaticall on crontab it doesn't complete the process.
The script is :
#!/usr/local/bin/expect
spawn telnet 192.168.1.1
expect "login:"
send "root\r"
expect "Password:"
send "<password>\r"
send "bash\r"
send "cd /opt\r"
send "reboot\r"
interact
the output of the script ( when it is run by cron )
spawn telnet 192.168.1.1
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.
DD-WRT v24-sp2 std (c) 2010 NewMedia-NET GmbH
Release: 08/07/10 (SVN revision: 14896)
RK-SWOT-2 login: root
Password:
and that's it. no more go forward on the cron. Can you help me for this ?
I've fixed the issue.
I think the problem was with the interact command. I changed it to
expect eof
and the problem gone.