我使用的是python2.7和pexpect 4.6.0
根据pexpect
docs:
If you wish to read up to the end of the child’s output without generating an
EOF
exception then use theexpect(pexpect.EOF)
method.
但当我这么做时,它会引发EOF
异常。我如何期望EOF并获得子级返回的所有输出?在
child = pexpect.spawn("ssh user@server")
child.expect("[pP]assword")
child.sendline("password")
child.expect("\$")
print child.before + child.after
child.sendline("ifconfig")
child.expect(pexpect.EOF) # this throws Exception
文件中还说:
Some UNIX platforms will throw an exception when you try to read from a file descriptor in the EOF state. Other UNIX platforms instead quietly return an empty string to indicate that the EOF state has been reached.
我们怎么知道这是不是问题?有什么解决办法呢?在
目前没有回答
相关问题 更多 >
编程相关推荐