problems while using pexpect: pexcept.TIMEOUT always

P

Phoe6

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@localhost's password:
senthil@ubuntu:~$

And here is my pexpect script:

http://paste.pocoo.org/show/121788/

And the output I get is:

True
None
None
Traceback (most recent call last):
File "4.py", line 17, in <module>
print child.read()
File "/usr/local/lib/python2.6/site-packages/pexpect.py", line 858,
in read
self.expect (self.delimiter) # delimiter default is EOF
File "/usr/local/lib/python2.6/site-packages/pexpect.py", line 1311,
in expect
return self.expect_list(compiled_pattern_list, timeout,
searchwindowsize)
File "/usr/local/lib/python2.6/site-packages/pexpect.py", line 1325,
in expect_list
return self.expect_loop(searcher_re(pattern_list), timeout,
searchwindowsize)
File "/usr/local/lib/python2.6/site-packages/pexpect.py", line 1409,
in expect_loop
raise TIMEOUT (str(e) + '\n' + str(self))
pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().

Complete Traceback is here:
http://paste.pocoo.org/show/121790/

Can someone help me what I am doing wrong here?
Why is not working for such a simple thing as ssh to my localhost.?

I am getting the same problem while trying to login to remote host
also.

Thanks,
Senthil
 
R

R. David Murray

Phoe6 said:
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.
[...]

Can someone help me what I am doing wrong here?
Why is not working for such a simple thing as ssh to my localhost.?

I would suggest using the 'setlog' method of child to get
more debugging information from pexpect. I've found that the
best way to diagnose the source of a timeout.
 
S

Senthil Kumaran

I would suggest using the 'setlog' method of child to get
more debugging information from pexpect.  I've found that the
best way to diagnose the source of a timeout.

setlog method seems to be deprecated and 'not allowed' too as the help
says.
But, I just figured out with help from another forum (bangpypers) that
I was not closing the ssh session.
so doing child.sendline('logout') and then doing child.read() in my
script worked out.

Thanks,
Senthil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top