I would like to execute some program through ssh and redirect its input from a file. The behaviour of the following code:
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
should be equivalent to (assuming public-key authentication):
ssh user@host cat < mumu
However the application hangs waiting for more input. I think this happens because the stdin stream is never closed. How do I do that?