def run_command(name): cmd = "ssh -l root %s %s" % (host, name) p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, close_fds=True) stdout, stderr = p.communicate() stdout = stdout.rstrip() stderr = stderr.rstrip() ret = RemoteCommand() # TODO rethink difference between no line and single empty line if stdout: for line in stdout.split('\n'): ret.stdout.push_back(line) if stderr: for line in stderr.split('\n'): ret.stderr.push_back(line) ret.exit_code = p.returncode return ret
def run_command(name): cmd = "ssh -l root %s -p %s %s" % (host, port, name) p = Popen(cmd, shell = True, stdout = PIPE, stderr = PIPE, close_fds = True) stdout, stderr = p.communicate() stdout = stdout.rstrip() stderr = stderr.rstrip() ret = RemoteCommand() # TODO rethink difference between no line and single empty line if stdout: stdout = stdout.decode("utf-8") for line in stdout.split('\n'): ret.stdout.push_back(line) if stderr: stderr = stderr.decode("utf-8") for line in stderr.split('\n'): ret.stderr.push_back(line) ret.exit_code = p.returncode return ret
def run_command(name): cmd = "ssh -l root %s %s" % (host, name) p = Popen(cmd, shell = True, stdout = PIPE, stderr = PIPE, close_fds = True) stdout, stderr = p.communicate() ret = RemoteCommand() for line in stdout.rstrip().split('\n'): ret.stdout.push_back(line) for line in stderr.rstrip().split('\n'): ret.stderr.push_back(line) ret.exitcode = p.returncode return ret