I would like to execute some program via ssh and redirect its input from a file. The behavior 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 (subject to public key authentication):
ssh user@host cat < mumu
However, the application freezes, expecting more input. I think this is because the stdin thread never closes. How to do it?
source share