[BangPypers] problems while using pexpect. pexpect.TIMEOUT always...

Gora Mohanty gora at srijan.in
Mon Jun 8 19:09:00 CEST 2009

On Mon, 8 Jun 2009 21:48:50 +0530
Senthil Kumaran <orsenthil at gmail.com> wrote:

> I have been trying to use pexpect and I am failing with
> pexpect.TIMEOUT for all my attempts. In order to troubleshoot, I
> decided to go with simplest possible one.
> Here is my ssh to localhost:
> [21:29:14 senthil]$ssh localhost -l senthil
> senthil at localhost's password:
> senthil at ubuntu:~$
> And here is my pexpect script:
> http://paste.pocoo.org/show/121788/

I am not very familiar with pexpect, but from what I remember
of Expect, there are a couple of issues here:
o You should be using p.expect() instead of time.sleep()
o After issuing a 'fortune' command you should be expecting a
  shell prompt.
o You should explicitly close the connection by logging out

Please see http://paste.pocoo.org/show/121800/ where I have used
'ls' instead of 'fortune' as I did not have the latter installed.
The pattern matches anything, i.e., whatever be the shell prompt,
and child.expect also matches EOF.


More information about the BangPypers mailing list