1

I need to run a command via rpyc and get the result of this command.

But whenever I run the command, it is printed on the remote server and can not bring the result.

What I am doing is the following:

import os, sys
import rpyc

conn = rpyc.classic.connect('server_remote')
a = conn.modules.os.system( "ls -lh")

print a

The output of my command is 0 for any command I run.

python get_output.py
0
Diogo Leal
  • 97
  • 1
  • 5
  • this has got nothing to do with rpyc. you'd get the same behavior if you just run `system( "ls -lh")` locally (accept that stdout would be local to the process). – shx2 Oct 22 '14 at 06:25

1 Answers1

1

Use os.popen or subprocess.checked_output instead of system. System just returns the exit code, while the output is printed to your stdout (i.e. you don't get hold of it programmatically)

sebulba
  • 1,245
  • 2
  • 10
  • 17