PXSSH Remote execution Command error handling

Source: Internet
Author: User

Test environment: Ubuntu12.04

Python-pexpect Installation: Apt-get install Python-pexpect


Test script:

#!/usr/bin/env pythonimport pxsshimport getpasstry:    s =  Pxssh.pxssh ()     hostname = raw_input (' hostname:  ')      Username = raw_input (' username:  ')     password = getpass.getpass ( ' please input password:  ')     s.login (hostname, username,  Password)     s.sendline (' uptime ')     s.prompt ()      print s.before    s.sendline (' ls -l ')     s.prompt ()     print s.before    s.sendline (' DF ')      S.prompt ()     print s.before    s.logout () except pxssh. exceptionpxssh, e:    print  "Pxssh failed on login."     print str (e)

Error when executing:

Traceback (most recent):

File "pxsshsimple1.py", line 9, <module>

S.login (hostname, username, password)

File "/usr/lib/python2.7/dist-packages/pxssh.py", line 243, in login

If not self.synch_original_prompt ():

File "/usr/lib/python2.7/dist-packages/pxssh.py", line 134, in Synch_original_prompt

Self.read_nonblocking (size=10000,timeout=1) # Gas:clear out the cache before getting the prompt

File "/usr/lib/python2.7/dist-packages/pexpect.py", line 824, in read_nonblocking

Raise timeout (' timeout exceeded in read_nonblocking (). ')

Pexpect. Timeout:timeout exceeded in read_nonblocking ().


Modify the/usr/lib/python2.7/dist-packages/pxssh.py file to add before the line134 line:

Self.sendline () time.sleep (0.5)


PXSSH Remote execution Command error handling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.