On Oct 24, 12:07 pm, mrstephengross <[EMAIL PROTECTED]>
wrote:
> 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?

>>> print "%#x" % 1280
0x500     # first byte is your exit code; second gives signal info if
any
>>>

In any case, the best approach is to use the os module to interpret it
as given in other post (os.WEXITSTATUS(1280))

Karthik

>
> Thanks,
> --Steve


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to