pushyrpc / pushy

Easy-as RPC. Zero-server RPC for Python and Java.
http://github.com/pushyrpc/pushy
45 stars 18 forks source link

Get return of command #53

Closed arist0v closed 9 years ago

arist0v commented 9 years ago

Hello, i use the following command: con.modules.os.system("hostname") the only return i get is 0. how could i get the return of command remotly executed?

thank you

Arist0v

axw commented 9 years ago

@arist0v Don't use os.system. This is not particular to Pushy; if you were in a Python interpreter, os.system would return the exit code (e.g. 0) and print the hostname to stdout.

If you want to run an arbitrary command and get its stdout as a result, then I suggest you use the subprocess package. e.g. con.modules.subprocess.Popen(["hostname"], stdout=con.modules.subprocess.PIPE).communicate()

(if you just want the hostname, then use the platform package)

axw commented 9 years ago

Closing, as there is no issue with Pushy. I have confirmed that the above works.