Getting return value in os.system rsh call

Donn Cave donn at u.washington.edu
Wed Jan 29 14:42:25 EST 2003


Quoth migmog99 at hotmail.com (Andrew):
| I'm writing a test script which kicks off tests on remote machines,
| and I need to get the return code from the remote test in my main
| program.
|
| the relevent bit is
|
| os.system("rsh remote test.py")
|
| How can I get the return value of test.py?
|
| any ideas?

Depends.  In what sense does test.py have a return value?  Do you
mean its exit status?

The only thing you can get back from rsh is output, for which you'll
need popen() instead of system().  If you want the exit status, that
will have to be converted to output on the remote side ... like,
   "rsh remote -n 'test.py; echo exit status $?'"

("-n" means don't consume input.  rsh supports I/O both ways, but
can't tell if it's going to be used, so it will take a buffer full
if it can get it.  That can cause problems in a batch context.)

	Donn Cave, donn at u.washington.edu




More information about the Python-list mailing list