os.system error returns

Ben Finney ben+python at benfinney.id.au
Fri Jun 12 09:43:04 EDT 2015


Grawburg <grawburg at myglnc.com> writes:

> if os.system('modprobe --first-time -q w1_gpio') ==0
>
> if os.system('modprobe -q w1_gpio') == 256:
>
> I know what the 'modprobe...' is, it's the 0 and the 256 I don't get.
> Where do these numbers come from?

They are integer literals, they come from the source code.

The statements are comparing those integers to the return value from
‘os.system’. The return value from ‘os.system’ is whatever was the child
process sets as its exit status.

> I recognize they're some kind of error returns, but don't know what
> they mean.

That's not up to Python, it's entirely set by the external program.

There is no standardisation of exit status values between different
programs. The best one can say is “exit status 0 means success”.
Anything further is specific to particular programs and is not
universal.

You'll need to see the documentation for ‘modprobe(1)’ to find out what
its different exit status values mean.

-- 
 \       “The Vatican is not a state.… a state must have people. There |
  `\    are no Vaticanians.… No-one gets born in the Vatican except by |
_o__)        an unfortunate accident.” —Geoffrey Robertson, 2010-09-18 |
Ben Finney




More information about the Python-list mailing list