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


Groups > comp.lang.python > #92521

Re: os.system error returns

From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: os.system error returns
Date 2015-06-12 13:48 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <mlenvo$b5p$1@reader1.panix.com> (permalink)
References <mailman.419.1434115180.13271.python-list@python.org>

Show all headers | View raw


On 2015-06-12, Grawburg <grawburg@myglnc.com> wrote:
> I have a piece of code written for a Raspberry Pi with no explanation for two of the lines -- and I can't find an explanation I understand.
>
> Here are the lines:
> 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? I recognize they're some kind of
> error returns, but don't know what they mean.

In generail, Linux command line utilities return 0 to indicate
success/OK/true. They return non-zero to indicate failure/error/false.

The status you get back from os.system() on linux is a 16-bit number
with the the upper 8 bits the return value from the command and the
lower 8 bits the signal number that terminated the sub-process (0
means normal exit).

So os.system() will return 0 if the command it invoked executed
successfully and returned a 0, and os.system() returns 256 if the
command it invoked returned a 1.

-- 
Grant Edwards               grant.b.edwards        Yow! Did I say I was
                                  at               a sardine?  Or a bus???
                              gmail.com            

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


Thread

os.system error returns Grawburg <grawburg@myglnc.com> - 2015-06-12 09:07 -0400
  Re: os.system error returns Grant Edwards <invalid@invalid.invalid> - 2015-06-12 13:48 +0000

csiph-web