4
我想通過ssh執行一些程序並將其輸入從文件中重定向。下面的代碼的行爲:如何將EOF發送到paramiko的stdin?
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
應該等於(假設公鑰認證):
ssh [email protected] cat < mumu
但是應用程序掛起等待更多的輸入。我認爲這是因爲stdin流永遠不會關閉。我怎麼做?
然後stdout和stderr會發生什麼? – Alexandru 2010-03-31 16:09:08
@Alexandru:我的功能錯了。 – 2010-03-31 16:15:18