Pexpect and telnet not communicating properly

Mark Wooding mdw at distorted.org.uk
Tue Jan 27 21:37:03 CET 2009


David Anderson <lists at pern.co.uk> writes:

> I am trying to automate the following session - to talk to my router:
>
> telnet speedtouch
[...]
> I am using the following code:
[...]
> child.expect('sername : ')
> child.sendline('Administrator')

I've scripted communications with my Speedtouch 510 using pexpect: I use
it to send the router's logs to my server.  The obvious difference
between my script and yours is that instead of sendline, I used send and
an explicit carriage return.

        kid.expect('Username :')
        kid.send('admin\r\n')

I think this is a result of a similar problem, but I don't remember any
more.

Anyway, I've put my (very simple) script up at

        http://www.distorted.org.uk/~mdw/example/guvnor-maintenance

in case you're interested.  (No, I wasn't daft enough to put the
password in the script!)

-- [mdw]



More information about the Python-list mailing list