1

Using Python and paramiko, I have the following code

(stdin, stdout, stderr) = self.client.exec_command(x)
b = stderr.readlines()
if b:
    for i in b:
        print i
a = stdout.readlines()
if a:
    for i in a:
        print i

The command I run takes ~15 minutes and outputs a steady update to stdout, but it won't print on the host side until it's completed.

Is there a way to get the live stdout as opposed to waiting? Thanks.

user3000724
  • 651
  • 3
  • 11
  • 22
  • Possible duplicate of [get output from a paramiko ssh exec\_command continuously](http://stackoverflow.com/questions/31834743/get-output-from-a-paramiko-ssh-exec-command-continuously) – sethmlarson Mar 11 '16 at 16:15

1 Answers1

1

Just repeatedly call stdout.readlines(). It will trigger flushing if any data in buffer.

John Hua
  • 1,400
  • 9
  • 15