Redirecting system output quietly
db3l at fitlinxx.com
Tue Nov 16 18:51:00 CET 2004
hugonz at hotmail.com (Hugo Gonz?lez) writes:
> There's an even easier way to do this. You can use the "commands"
> This is easier and faster than using popen, and will allow you to get
> exit status (os.popen* won't let you)
Well, since the commands module is just a simple wrapper around the
os.popen() call, it's hard to see it giving you anything you can't get
with the call itself :-)
You can certainly get the exit status from os.popen - it is returned
as the result of the close() operation. (Under Windows, for the
higher order popen* calls, you get the exit status from the close() on
the final of the multiple handles you close, while under Unix I think
you need to explicitly do a wait() on the returned handle).
One thing to be aware of with commands (although this shouldn't be a
problem for the OP in this case), is that it is Unix only, and won't
work properly under Windows.
More information about the Python-list