[wplug] Bash Expect usage - Automating telnet

Vance Kochenderfer vkochend at nyx.net
Fri May 9 00:07:15 EDT 2014


scoob8000 <scoob8000 at gmail.com> wrote:
> So I've never used expect before and I'm really struggling.   I'm
> trying to come up with a script to telnet into a bunch of devices, run
> a few commands then log it.

I'm assuming you have no better way of changing passwords on these
devices; ssh offers an easy way to do a one-shot command.

I don't know enough about expect to give specific help, but if you
can explain how your script is failing maybe someone with more
experience can chime in.  One thing to look at might be the
newlines you're sending at the end of commands - does the device
want a CR, an LF, or a CRLF?

Another option you may want to investigate is using netcat (aka
nc) instead of the normal telnet client within your script.  It
seems to work better for non-interactive use.

There are a number of cluster administration tools for running the
same command on multiple hosts.  Nearly all use ssh or rsh.  One
that claims to also work via telnet is PyDSH
<http://sourceforge.net/projects/pydsh/>.  This might be an
alternative to try, but I've never used it.

Vance Kochenderfer        |  "Get me out of these ropes and into a
vkochend at nyx.net          |   good belt of Scotch"    -Nick Danger


More information about the wplug mailing list