capturing system exit status

Michael Hoffman cam.ac.uk at mh391.invalid
Mon Apr 2 03:35:51 CEST 2007


oscartheduck wrote:

> in a program I'm writing I have several commands I pass to the unix OS
> underneath the code.
> 
> I want to perform error checking to make sure that the OS commands'
> exit gracefully, but I'm not seeing a simple python module to do this.

If you're using Python 2.5, you can use subprocess.check_call() which 
will raise CalledProcessError for nonzero exit code. If you're using 
Python 2.4, you can use retcode = subprocess.call() and check it yourself.
-- 
Michael Hoffman



More information about the Python-list mailing list