Easiest way to get exit code from os.popen()?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Oct 29 00:18:54 EDT 2007


En Wed, 24 Oct 2007 16:07:44 -0300, mrstephengross  
<mrstephengross at hotmail.com> escribi�:

> Hi folks. I'm using os.popen() to run a command; according to the
> documentation, the filehandle.close() oepration is suppsoed to return
> the exit code. However, when I execute something like "exit 5",
> close() returns 1280. Here's the code:
>
>   pipe = os.popen("exit 5")
>   print pipe.close() # prints 1280
>
> Am I doing something wrong? Is there an easier way to get the exit
> code?

Read the docs again...

-- 
Gabriel Genellina




More information about the Python-list mailing list