How To Get Continously Output Using Paramiko SSHClient
I want to ssh to remote server and run some shell scripts(like scp or yum etc). Everything went well except that I cant get continously stdout of sth like scp progress or yum downl
Solution 1:
stdout.read(N)
returns only when N bytes has been read or it gets EOF. The stdout.channel.recv(N)
returns as soon as there are new data available.
This works fine for me:
stdin, stdout, sterr = ssh.exec_command(cmd, get_pty=True)
while True:
v = stdout.channel.recv(1024)
if not v:
break
sys.stdout.write(v)
sys.stdout.flush()
Post a Comment for "How To Get Continously Output Using Paramiko SSHClient"