Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #92520

Re: os.system error returns

From Ben Finney <ben+python@benfinney.id.au>
Subject Re: os.system error returns
Date 2015-06-12 23:43 +1000
References <2ebdfdf225c075b2f5ef350b06bc14f0@myglnc.com>
Newsgroups comp.lang.python
Message-ID <mailman.420.1434116599.13271.python-list@python.org> (permalink)

Show all headers | View raw


Grawburg <grawburg@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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: os.system error returns Ben Finney <ben+python@benfinney.id.au> - 2015-06-12 23:43 +1000
  Re: os.system error returns Grant Edwards <invalid@invalid.invalid> - 2015-06-12 13:53 +0000

csiph-web