Strange return value from os.system(...) call

Andrew McNamara andrewm at object-craft.com.au
Wed Oct 13 00:05:07 EDT 2004


>I have a shell script that exits out with either a 0 or 1...and am 
>experiencing a strange phenomenon...
>
>somevalue=os.system("/path/to/script")
>print "somevalue:"+str(somevalue)
>
>If my script exits with 0, somevalue is 0
>...if it exits with 1, somevalue is 256

You probably want to read:

    http://python.org/doc/2.3.4/lib/os-process.html

You'll want to use something like:

    if os.WIFEXITED(status):
        print 'exited with status %d' % os.WEXITSTATUS(status)

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/



More information about the Python-list mailing list