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


Groups > comp.lang.python > #92522

Re: os.system error returns

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'terminated': 0.07; 'get.': 0.09; 'lines:': 0.09; 'normally,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'returns,': 0.09; 'python': 0.11; 'subject:error': 0.11; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.16; 'byte': 0.18; '>>>': 0.20; 'recognize': 0.22; 'written': 0.24; 'example': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'error': 0.27; 'piece': 0.29; 'lines': 0.30; "skip:' 10": 0.30; 'convention': 0.31; 'error.': 0.31; 'code': 0.31; "can't": 0.32; 'url:python': 0.33; 'to:addr:python-list': 0.35; 'but': 0.36; 'url:org': 0.36; "let's": 0.36; 'url:library': 0.36; 'two': 0.37; 'subject:: ': 0.37; 'instead': 0.38; 'received:org': 0.38; 'is,': 0.38; 'means': 0.39; 'goes': 0.39; 'url:2': 0.39; 'url:docs': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'received:de': 0.40; 'some': 0.40; 'free': 0.61; 'details': 0.63; 'here': 0.66; 'upper': 0.76; 'non-zero': 0.84; 'mean.': 0.91; 'url:system': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: os.system error returns
Date Fri, 12 Jun 2015 15:52:01 +0200
Organization None
References <2ebdfdf225c075b2f5ef350b06bc14f0@myglnc.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bd959e.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.421.1434117138.13271.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1434117138 news.xs4all.nl 2946 [2001:888:2000:d::a6]:55733
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:92522

Show key headers only | View raw


Grawburg 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.

By convention a return value of 0 means that the invoked program terminated 
normally, non-zero returns indicate an error. For the details you have to 
look into the modprobe documentation.

The invoked program is free to return a value in the range 0...255 which 
then goes into the upper byte of the return value of os.system(). For 
example let's use python instead of modprobe:

>>> os.system("python -c 'exit(42)'")
10752

You don't recognize the 42? Then how about

>>> os.system("python -c 'exit(42)'") >> 8
42

Read

https://docs.python.org/2.7/library/os.html#os.system

for the details.

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


Thread

Re: os.system error returns Peter Otten <__peter__@web.de> - 2015-06-12 15:52 +0200

csiph-web