473,378 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

read_nonblocking error in pxssh

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@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@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
Jan 16 '08 #1
2 14655
Just glanced at the docs, but it might be worth a shot...

try:
>import pxssh
s=pxssh.pxssh()
s.login("myhost","root","mypass", auto_prompt_reset=False)
Maybe???

Otherwise, I have used and modified this script with great success:

(ssh_session.py) http://www.koders.com/python/fidA430...B4EEE63CF.aspx

Good luck.

~Sean

On Jan 16, 9:24*am, jrpfinch <jrpfi...@gmail.comwrote:
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@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@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
Jan 16 '08 #2
On Feb 1, 4:31 pm, Jinno <jeremiah.ji...@gmail.comwrote:
I don't know if anyone ever got back to you with a fix, but for me the
fix was really simple.

I just added a self.sendline() and a time.sleep(0.5) right before the
first read_nonblocking() call within synch_original_prompt
Thank you!!! That was exactly the right solution, and thank you very
much for the great explanation too.

---Kayvan
Feb 2 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
by: Gregory | last post by:
Hi, One of the disadvantages of using error handling with error codes instead of exception handling is that error codes retuned from a function can be forgotten to check thus leading to...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
1
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly,...
1
by: tereglow | last post by:
Hello, I am trying to convert some Expect/Tcl code into Python by using the Pexpect module. The environment is such that authenticated keys are disabled although SSH is available. I do not...
7
by: gert | last post by:
This works but after the su command you have to wait like 2 minutes before each command gets executed ? What did i do wrong ? import pxssh try: s = pxssh.pxssh() s.login ('127.0.0.1',...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.