read_nonblocking error in pxssh

jrpfinch jrpfinch at gmail.com
Wed Jan 16 12:24:27 EST 2008


I'm attempting to use the pxssh to execute commands on a remote
machine and do stuff with the output.  Both machines are running SSH
Version Sun_SSH_1.0, protocol versions 1.5/2.0 and Intel Solaris 9.

I am hitting a problem with read_nonblocking in the pexpect module as
follows:

>>> import pxssh
>>> s=pxssh.pxssh()
>>> s.login("myhost","root","mypass")
Trying command: ssh -q -l root gerard
Expect returned i=2
Expect returned i=1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pxssh.py", line 244, in login
    if not self.synch_original_prompt():
  File "pxssh.py", line 134, in synch_original_prompt
    self.read_nonblocking(size=10000,timeout=10) # GAS: Clear out the
cache before getting the prompt
  File "/opt/python2.5.1/lib/python2.5/site-packages/pexpect.py", line
824, in read_nonblocking
    raise TIMEOUT ('Timeout exceeded in read_nonblocking().')
pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().

Running the ssh command from the shell yields:

bash-2.05# ssh -q -l root myhost
root at myhost's password:
Last login: Wed Jan 16 17:10:32 2008 from x.x.x.x
Sun Microsystems Inc.   SunOS 5.9       Generic January 2003
Sun Microsystems Inc.   SunOS 5.9       Generic January 2003
root at myhost:/ #

I would be grateful if anyone could make a suggestion as to where I go
next?  Is read_nonblocking(), the correct method to be using here?
Are there any options in pxssh I need to explore (I've tried ssh -t,
but this means the password entry fails with raise ExceptionPxssh
('password refused')).

Many thanks

Jon



More information about the Python-list mailing list