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


Groups > comp.lang.python > #92518 > unrolled thread

os.system error returns

Started byGrawburg <grawburg@myglnc.com>
First post2015-06-12 09:07 -0400
Last post2015-06-12 13:48 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  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

#92518 — os.system error returns

FromGrawburg <grawburg@myglnc.com>
Date2015-06-12 09:07 -0400
Subjectos.system error returns
Message-ID<mailman.419.1434115180.13271.python-list@python.org>
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.


Thanks,
Brian Grawburg



[toc] | [next] | [standalone]


#92521

FromGrant Edwards <invalid@invalid.invalid>
Date2015-06-12 13:48 +0000
Message-ID<mlenvo$b5p$1@reader1.panix.com>
In reply to#92518
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            

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web