tgc*_*oud 3 pexpect python-2.7
有了 pexpect,我正在生成子进程并执行“ssh”远程框。从过去的许多天开始,它工作得很好,突然现在,每当我尝试生成子进程时,它就会抛出以下错误。不知道发生了什么事。
直到现在我使用 pexpect 3.1,我遇到了这个问题。所以我将其升级到3.2,但仍然面临同样的问题。
>>> child = pexpect.spawn('ssh -o StrictHostKeyChecking=no centos@192.168.2.23')
>>> child.expect([pexpect.TIMEOUT,'[P|p]assword: '])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pexpect/__init__.py", line 1418, in expect
timeout, searchwindowsize)
File "/usr/lib/python2.7/dist-packages/pexpect/__init__.py", line 1433, in expect_list
timeout, searchwindowsize)
File "/usr/lib/python2.7/dist-packages/pexpect/__init__.py", line 1521, in expect_loop
raise EOF(str(err) + '\n' + str(self))
pexpect.EOF: End Of File (EOF). Exception style platform.
<pexpect.spawn object at 0x7fe923a8b710>
version: 3.2
command: /usr/bin/ssh
args: ['/usr/bin/ssh', '-o', 'StrictHostKeyChecking=no', 'centos@192.168.2.23']
searcher: <pexpect.searcher_re object at 0x7fe923a8b750>
buffer (last 100 chars): ''
before (last 100 chars): 'AL PROSECUTION.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,keyboard-interactive).\r\r\n'
after: <class 'pexpect.EOF'>
match: None
match_index: None
exitstatus: 255
flag_eof: True
pid: 2202
child_fd: 3
closed: False
timeout: 30
delimiter: <class 'pexpect.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
Run Code Online (Sandbox Code Playgroud)
child.expect([pexpect.TIMEOUT, \'pattern\', pexpect.EOF])\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\n当您尝试读取处于 EOF 状态的文件描述符时,某些 UNIX 平台将引发异常。其他 UNIX 平台则悄悄地返回一个空字符串来指示已达到 EOF 状态。
\n
\n 如果您希望读取到 child\xe2\x80\x99s 输出的末尾而不生成 EOF 异常,请使用该expect(pexpect.EOF)方法。
详细信息你可以关注这个。
\n\n希望对您有所帮助。
\n| 归档时间: |
|
| 查看次数: |
18595 次 |
| 最近记录: |