Getting return value in os.system rsh call

Andrew migmog99 at hotmail.com
Thu Jan 30 12:09:24 CET 2003


Chaps - Thanks for your help, but unfortunately it's still not doing
what I want! This seems to be more a problem with rsh than with
python.

I've simplified the problem as much as possible, and when I try the
following from a command prompt, I get this result. This is cut &
pasted straight off my terminal, with only the host names changes to
protect the innocent..

BTW: Anyone know how to avoid the 'stty standard input: Invalid
argument' messages?

I wrote a very simple python program which simply outputs what host
it's running on and returns an unmistakeable return value:

10:49:01$ cat bad.py
#!/usr/bin/env python
import os, sys
os.system("hostname")
sys.exit(123)

When I run it locally, it does what you'd expect:

10:49:04$ ./bad.py; echo $?
local
123

But when I run it remotely I get this odd result:

10:49:09$ rsh -n remote "./bad.py; echo $?"
stty: standard input: Invalid argument
stty: standard input: Invalid argument
remote
0

Double checking that the 'echo $?' is coming from the remote host:

10:49:32$ rsh -n remote "./bad.py; echo $?; hostname"
stty: standard input: Invalid argument
stty: standard input: Invalid argument
remote
0
remote

Maybe there's something odd with the machine 'remote' - try rsh'ing to
ourself... no difference

10:49:44$ rsh -n local "./bad.py; echo $?; hostname"
stty: standard input: Invalid argument
stty: standard input: Invalid argument
local
0
local




More information about the Python-list mailing list