#264403 - 05/09/2005 12:58
Scripted telnet access from Windows
|
carpal tunnel
Registered: 18/01/2000
Posts: 5683
Loc: London, UK
|
So, we've got a managed switch in our lab that I'd like to reconfigure as part of our automated build process. It's got telnet access, so it should be fairly easy.
What I want are pointers to programs like 'chat' (the one that used to be used with pppd), but that run on Windows and talk telnet.
Suggestions?
_________________________
-- roger
|
Top
|
|
|
|
#264404 - 05/09/2005 13:09
Re: Scripted telnet access from Windows
[Re: Roger]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14493
Loc: Canada
|
puTTY ?
EDIT: Oh wait, are you specifically after scriptable clients? I suppose so, from the subject line.
Edited by mlord (05/09/2005 13:10)
|
Top
|
|
|
|
#264406 - 05/09/2005 14:04
Re: Scripted telnet access from Windows
[Re: Roger]
|
carpal tunnel
Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
|
Quote: Suggestions?
Expect?
Peter
|
Top
|
|
|
|
#264407 - 05/09/2005 14:05
Re: Scripted telnet access from Windows
[Re: mlord]
|
carpal tunnel
Registered: 18/01/2000
Posts: 5683
Loc: London, UK
|
Quote: EDIT: Oh wait, are you specifically after scriptable clients? I suppose so, from the subject line.
Yeah. The switch has a telnet-accessible command-prompt configuration interface. I want to connect to it, wait for 'Username', send the username, wait for 'Password', send the password, wait for '#', send the command sequence, wait for 'OK', send another command, and so on...
Kinda like I used to have to do with 'chat' with dial-up PPP connections on Linux.
This should all be scriptable from the Windows command line. I don't need any kind of GUI, since it'll all be unattended (when I've finished).
I found a copy of 'expect' in Cygwin, but I don't know if it'll do what I want, and I don't know how to use it, anyway.
I'll take a closer look at your list later, thanks.
_________________________
-- roger
|
Top
|
|
|
|
#264408 - 05/09/2005 14:22
Re: Scripted telnet access from Windows
[Re: peter]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Quote:
Quote: Suggestions?
Expect?
Peter
Yes, expect is ideal for this task. I've used it before to do exactly this. Basically you give it a string to send, then a range of strings to 'expect' that can trigger different responses. You can set a timeout clause that will trigger if none of the other responses get triggered first etc.
I also used expect to modify my hijack Makefile - I modified the 'install' target to call an expect script that would ftp hijack to my player and reboot it if successful.
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#264409 - 05/09/2005 15:22
Re: Scripted telnet access from Windows
[Re: genixia]
|
carpal tunnel
Registered: 29/08/2000
Posts: 14493
Loc: Canada
|
Quote:
I also used expect to modify my hijack Makefile - I modified the 'install' target to call an expect script that would ftp hijack to my player and reboot it if successful.
My install script does something similar, but without expect. It actually performs a full readback of the kernel from flash and compares with the original to ensure correct flash contents before rebooting:
Quote:
echo "Sending kernel.." ftp -n >/dev/null <<-EOF open $IP
#passive site popup 99 Downloading kernel.. put $ZIMAGE /proc/empeg_kernel site popup 99 Waiting for readback.. get /proc/empeg_kernel /tmp/junk site popup 0 Done. quit EOF bytes=`ls -l $ZIMAGE|awk '{print $5}'` dd if=/tmp/junk bs=$bytes count=1 2>/dev/null | diff $ZIMAGE - if [ "$?" = "0" ]; then echo "Success!" else echo "FAILED -- try again!" exit 1 fi rm -f /tmp/junk 2>/dev/null echo "Rebooting.." ftp >/dev/null <<-EOF open $IP
site reboot EOF
|
Top
|
|
|
|
#264410 - 05/09/2005 18:56
Re: Scripted telnet access from Windows
[Re: Roger]
|
member
Registered: 19/03/2002
Posts: 144
Loc: Florida, USA
|
You need:
ActivePerl (Since this is on Winders)
Net::Telnet (from Perl CPAN)
Net::Telnet::Cisco automates my whole Cisco switch/router subnet, its a joke how easy it is.
Edited by shadow45 (05/09/2005 18:58)
_________________________
::: shadow45
|
Top
|
|
|
|
#264411 - 05/09/2005 20:19
Re: Scripted telnet access from Windows
[Re: shadow45]
|
carpal tunnel
Registered: 18/01/2000
Posts: 5683
Loc: London, UK
|
Quote: Net::Telnet::Cisco automates my whole Cisco switch/router subnet, its a joke how easy it is.
Looks good. Unfortunately, this is a D-Link .
_________________________
-- roger
|
Top
|
|
|
|
#264412 - 06/09/2005 03:36
Re: Scripted telnet access from Windows
[Re: Roger]
|
pooh-bah
Registered: 20/01/2002
Posts: 2085
Loc: New Orleans, LA
|
Sounds like just about any mud client I've used. Portal was my favorite, tinyfugue is also nice.
|
Top
|
|
|
|
#264413 - 06/09/2005 17:07
Re: Scripted telnet access from Windows
[Re: Roger]
|
member
Registered: 19/03/2002
Posts: 144
Loc: Florida, USA
|
Net::Telnet will let you automate any telnet session. I've used it for tons of things Net::Telnet::Cisco is for IOS.. makes it *even* easier
_________________________
::: shadow45
|
Top
|
|
|
|
|
|