How to get the return status of a command runned by os.popen4
barthe at magic.fr
Wed Sep 5 16:58:57 CEST 2001
> I've had good luck on Windows NT 4 with the following combination:
> cmdPipe = os.popen(aCmdLine)
> resultStream = cmdPipe.read()
> At this point you can read resultStream for any stdout feedback
> returned by aCmdLine. Is that what you need?
Not really. I catch easily stdout, stdin and stderr. My need is to catch
the decimal return code of the command. On UNIX, 0 means success,
anything else means failure.
With os.popen, the close method returns this decimal code:
cmdPipe = os.popen(aCmdLine)
return_code = cmdPipe.close()
With os.popen4, it does not :-(
Another idea ?
> Alain Barthe <barthe at magic.fr> wrote in message news:<3B93C945.EB6DF7A8 at magic.fr>...
> > Hi,
> > I cannot get the return status of a command runned by os.popen4 or
> > popen2.popen4. File closing does not return the status as os.popen does.
> > I can get it with an object popen2.popen4, but it's not Windows
> > compliant.
> > Anybody has the solution ?
> > Thanks.
More information about the Python-list