I have a wrapper around Paramiko SSHClient.exec_command() . I would like to get the standard version. Here's a shortened version of my function:
def __execute(self, args, sudo=False, capture_stdout=True, plumb_stderr=True, ignore_returncode=False): argstr = ' '.join(pipes.quote(arg) for arg in args) channel = ssh.get_transport().open_session() channel.exec_command(argstr) channel.shutdown_write()
In do_capture() , when channel.recv_ready() tells me that I can get data from the stdout command, I call channel.recv(1024) and add the data to my buffer. I stop when the exit status of the command is available.
However, it seems that more stdout data appears at some point after the exit status.
# We get data after the exit status is available, why? for i in xrange(100): do_capture()
I cannot just call do_capture() once, since it seems that channel.recv_ready() will return False in a few milliseconds and then True, and more data will be received, and then False again.
I am using Python 2.7.6 with Paramiko 1.15.2.
source share