[wplug] Help with expect - sending special chars

Nathan Embery nembery at met-net.com
Mon Sep 21 08:42:30 EDT 2009


I use the following idiom all the time:

#!/usr/bin/bash

cmd="clear counters interface all"
host=$1
port=23
login="%%%%%"
password="&&&&&&"

(/usr/bin/echo open $host $port
sleep 2
/usr/bin/echo "$login"
/usr/bin/echo "\r"
sleep 2
/usr/bin/echo "$password"
/usr/bin/echo "\r"
sleep 2
/usr/bin/echo "$cmd"
/usr/bin/echo "\r"
sleep 1
/usr/bin/echo "y"
/usr/bin/echo "\r"
sleep 1
/usr/bin/echo "close"
/usr/bin/echo "\r" ) | /usr/bin/telnet


HTH,
Nathan Embery
Systems Manager
nembery at met-net.com
c. 724 825 1168
o. 412 567 4318

Met-Net


On Fri, 2009-09-18 at 17:18 -0400, Paul Oehler wrote:

> > Any other ideas?  I just need to telnet to a device, send a command,
> > wait for a paticular response and send the next command.  Ideally I
> > could do this in some kind of loop too.
> 
> Expect really is the way to go for this kind of thing, it's designed just 
> this kind of interaction.  I'm not aware of anything else that makes this 
> kind of task easy.
> 
> Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.wplug.org/pipermail/wplug/attachments/20090921/c9c24548/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: met-net-web.png
Type: image/png
Size: 8777 bytes
Desc: not available
Url : http://www.wplug.org/pipermail/wplug/attachments/20090921/c9c24548/attachment.png 


More information about the wplug mailing list