I create a paramiko channel, then execute the command and get its output:
channel = transport.open_session() channel.exec_command('service myservice restart') stdout = channel.makefile('rb') for line in stdout: print line,
However, after executing the command (which ends), the iteration of the output is blocked.
I tested with ssh:
ssh myhost service myservice restart
So, I want to simulate the -t option in paramiko. So far I have tried:
channel = transport.open_session() channel.get_pty() channel.invoke_shell() stdin, stdout = channel.makefile('wb'), channel.makefile('rb') stdin.write('service myservice restart\n') for line in stdout: print line,
But now stdout does not close, and for never ends.
Any ideas?
source share