LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   telnet to reset modem > can't close (https://www.linuxquestions.org/questions/linux-newbie-8/telnet-to-reset-modem-cant-close-779228/)

CQ1ST 01-01-2010 08:24 AM

telnet to reset modem > can't close
 
Code:

#!/usr/bin/expect -f
spawn telnet 10.1.1.1
expect -re "login"
send "username\n"
expect -re "Password"
send "password\n"
expect #
send "reboot && sleep 70 && exit\n"
interact

reboot works great, but then I'm stuck in an unresponsive telnet session (&& sleep 70 && exit) does not work

how could I exit this?

carltm 01-01-2010 08:33 AM

The easy way is to remove the "&& sleep 70". The problem is that you
must disconnect before the telnet session is killed, which is less than
70 seconds. If you really want to stay connected, just reduce the number
of seconds before you run exit.

CQ1ST 01-01-2010 07:32 PM

yeah, I've got it to work - a bit tricky because of the reboot/lost connection

Code:

#!/usr/bin/expect -f
spawn telnet 10.1.1.1
expect -re "login"
send "username\n"
expect -re "Password"
send "password\n"
expect #
send "reboot && quit\n"
expect #
send "exit\n"
interact

finally does it perfectly


All times are GMT -5. The time now is 02:22 PM.