[Tutor] newbie: retrieving a program's return code via python

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Fri Apr 4 16:12:02 2003

On Fri, 4 Apr 2003, Terence Lo wrote:

> suppose my python script launches a command-line win32 application.
> how do i go about retrieving the return/exit code which that application
> sends out?

Hi Terence,

The os.system() function's return value should capture that value.  You
may want to look at:


closely --- os.system() tries to pack two values into a single number, so
it's a little tricky to use at first.  The documentation of os.wait()
(it's a little below the os.system() docs) explains which bits mean what.

Please feel free to ask questions about it if you get stuck on decoding
the return value.  Good luck to you!