Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #92521
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!not-for-mail |
|---|---|
| From | Grant Edwards <invalid@invalid.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: os.system error returns |
| Date | Fri, 12 Jun 2015 13:48:40 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 28 |
| Message-ID | <mlenvo$b5p$1@reader1.panix.com> (permalink) |
| References | <mailman.419.1434115180.13271.python-list@python.org> |
| NNTP-Posting-Host | 67-130-15-94.dia.static.qwest.net |
| X-Trace | reader1.panix.com 1434116920 11449 67.130.15.94 (12 Jun 2015 13:48:40 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Fri, 12 Jun 2015 13:48:40 +0000 (UTC) |
| User-Agent | slrn/1.0.2 (Linux) |
| Xref | csiph.com comp.lang.python:92521 |
Show key headers only | 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 | Next — Previous in thread | Find similar | Unroll 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