cannot get pexpect to work

Andrei dreico at wanadoo.fr
Sat Aug 30 15:20:35 EDT 2003


"Peter Hansen" <peter at engcorp.com> wrote in message
news:3F4FC7A6.37CF2C3 at engcorp.com...

> Best solution:  this is Python (!), so just start up an interactive
> session and type the relevant commands yourself, based on what you
> see in pexpect.py.  Not only will you solve the problem, but you'll
> end up with a much better understanding of pexpect.py and the passmass.py
> script as well.

An interactive session certainly did the trick.

>>> child = pexpect.spawn('ssh lxplus003 uptime')
>>> try:
...     child.expect('password:')
...     print "problem encountered, password needed"
... except Exception:
...     print "ok no passwd required"
...
0
problem encountered, password needed


I still haven't figured out why passmass.py isn't finishing and indeed times
out yet, but a basic understanding of pexpect is now creeping up on me, and
how it could help my project.

Thanks,

A.






More information about the Python-list mailing list