Re: expect/telnet

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Hey y'all,
> > This Project: I have to reset my modem thru a script
> > what I can do:
> > # I can telnet into the modem
> > it asks me for my password
> > then I gotta hit "r" to reset
> > then I gotta hit "y" as a confirmation
> > then it's done and I am back at the shell prompt
> > 
> > ....need to get turned on to a very basic get me started tutorial 
> > ....and maybe after that, w/luck, a really good telnet example in a
> > script.
> > ya, i know, I am asking a lot...like I just wanna sit back, suck my
> > thumb and twirl my hair and there it is. lol
> > I just need a good point in the right direction...google and the man
> > page didn't do me too much
and I still maintain that google and the man page didn't do me much. Of
course the man page is a must and man autoexpect as well

Thomas Cameron wrote:
> Look into autoexpect
there is no easier way to get your feet wet w/this than autoexpect.
thx Tom

Les Mikesell wrote:
> 
> Yet another way would be kermit.  It has a scripting language designed
> for chatting over serial ports which seems natural for this problem
> and it also works over tcp connections.  I used it long ago to
> initialize modems periodically through a scripted chat, then moved
> the modems to a terminal server and was able to continue to use
> the same script by just changing the serial port connection to
> a tcp address/port.

thx Les, but it's a dun deal now.

Jeff Kinz got me goin in the right direction, thx Jeff!

here's the finished script for all that might be interested:
-------------------------------------------------------------
#!/usr/bin/expect -f
# name: reset-zoom.exp
# by: rado@xxxxxxxxxxxxxxx ---"programming since fri nite"
# script to start the zoom 5X ADSL modem/router
# note: this script is not a norm "#!/bin/bash" script but rather an
except script
# note: this script originated by first recording it w/the following:
# autoexpect -c telnet 10.0.0.1
# and tweaking it using the "exit" command strategically placed for
debugging 

spawn telnet 10.0.0.1
expect "*********************************"
send -- "\r"
expect "Invalid password, please try again"
send  -- "****"
send  -- "****"
send  -- "***"
send  -- "\r"
expect "Enter your selection below:"
send  -- "r"
send  -- "\r"
expect "for main menu"
send  -- "y"
send  -- "\r"
expect eof
----------------------------------------------
password blanked for security in this script.
autoexpect produced ummm bout 150 lines of code/comment.
Jeff Kinz gave me a huge hint to use "exit". That was the key to getting
thru it. exit was a great debugging tool!
The password was really a bitch! I was never ever able to just put in my
password the first time. It would always say it was bad. So I just hit
return and put it in the 2nd time around. It was not as easy as just
writing it out and doing a "/r" ....keeps overwriting itself. seems like
max 4 chars at a time.
after tuning it all in, this format works fine.
It take about 1 sec. to run, the modem takes 16-18 seconds to reboot.
Thx y'all
John Rose
-- 
...and I woke up 2 days later, in the back yard, talkin to Elvis!


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux