Capturing standard out from a Paramiko command
问题 I have a wrapper around Paramiko's SSHClient.exec_command() . I'd like to capture standard out. 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() # Handle stdout and stderr until the command terminates captured = [] def do_capture(): while channel