简体   繁体   English

使用pxssh时出现非阻塞错误(Python的ssh模块)

[英]Read Non Blocking error while using pxssh (ssh module for python)

I am trying to do ssh on a remote machine using a python script using pxssh moudule. 我正在尝试使用pxssh moudule使用python脚本在远程计算机上执行ssh。

Here are the lines of code that I use for the same : 这是我用于同一行的代码行:

    s = pxssh.pxssh()
    s.login (hostip,'root',auto_prompt_reset=False)

But this gives me the following TIMEOUT error. 但这给了我下面的超时错误。

  Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/pxssh.py", line 243, in login
    if not self.synch_original_prompt():
  File "/usr/local/lib/python2.6/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/local/lib/python2.6/dist-packages/pexpect.py", line 824, in read_nonblocking
    raise TIMEOUT ('Timeout exceeded in read_nonblocking().')
pexpect.TIME

OUT: Timeout exceeded in read_nonblocking().

我已经更改了python库,而是使用更稳定的paramiko并不会出现上述错误。

I had the same problem. 我有同样的问题。 This post ( http://bytes.com/topic/python/answers/760027-read_nonblocking-error-pxssh ) had the solution. 这篇文章( http://bytes.com/topic/python/answers/760027-read_nonblocking-error-pxssh )提供了解决方案。

"I just added a self.sendline() and a time.sleep(0.5) right before the first read_nonblocking() call within synch_original_prompt()" “我刚刚在synch_original_prompt()中的第一次read_nonblocking()调用之前添加了self.sendline()和time.sleep(0.5)”

This solved the problem for me. 这为我解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM