我想通过ssh执行一些程序并将其输入从一个文件重定向。以下代码的行为:
channel.exec_command('cat')
with open('mumu', 'r') as f:
text = f.read()
nbytes = 0
while nbytes < len(text):
sent = channel.send(text[nbytes:])
if sent == 0:
break
nbytes += sent
应等效于(假设公钥身份验证):
^{pr2}$然而,应用程序挂起等待更多的输入。我想这是因为stdin流从未关闭过。我该怎么做?在
在通道上调用^{} (或
shutdown_write()
)。在调用方法:
channel.shutdown_write()
。在因为我没有明确地使用频道,所以我不得不做一些不同的事情。对于任何可能觉得有用的人:
相关问题 更多 >
编程相关推荐