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


Groups > comp.lang.python > #38729

Re: call shell from python

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'heavily': 0.04; 'skip:` 10': 0.05; 'variables,': 0.09; 'cc:addr:python-list': 0.10; 'subject:python': 0.11; '"use': 0.16; '9:13': 0.16; 'contrived': 0.16; 'luck,': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'feb': 0.19; 'import': 0.21; 'cc:2**0': 0.23; 'example': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; 'environment': 0.29; '>>>>': 0.29; 'url:python': 0.32; '11,': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'url:org': 0.36; 'url:library': 0.36; 'too': 0.36; 'subject:: ': 0.38; 'url:docs': 0.38; 'your': 0.60; 'more': 0.63; '\xe2\x80\x93': 0.75; '2013': 0.84; 'sender:addr:chris': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=s8ShvDQCBKn/6MYsjpy1/AHFvoLiDc6QT3aHyGwjTqg=; b=fmxEd/nI2j2osc0z7mPVPmxPDED1gXQJcZl2XveXZ9suEXtb7oGP0rZ9AMm786WawJ n3HBeYrFGrdaZt689v3a/BzKlZL+h75kcswoe5anb3hWcWuS35CcH/p9tDV+Bgk6TwLF kHLeem4cd5DKEit+j4ofj2/hz7mkoIFyify/E=
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding:x-gm-message-state; bh=s8ShvDQCBKn/6MYsjpy1/AHFvoLiDc6QT3aHyGwjTqg=; b=c2k/2yux/dI4+UirJ+MGUDUakkgHPV6PaoQrxMJx0CSzfI6wJIWIbmLfpb4C9URGB4 HS/xhaDAyS4DYkwrLbo0YhKikNU83IS1yo5Y2Lu6iem8UpJyM9v1tML6AdiSeYHOJTOa Sp9eBruq13HRIMXcaV2duhvI/MwckAE4WL7arFrW0TyqnHh9qSxOpntrOamC02Aomgtb r9Gdfa/v5gaxjgDDkg+YJk8gOu3bibLndKnAON/Fpz4/tobP2xRcOMp6/IMjffdavW3l 4Jo5ccNVtWDvOvrxMagDDcKZZ99DywGHvyz9KeS/hzCHCmgkUvmeQOxVQg7NJopQLV4i aTQg==
MIME-Version 1.0
X-Received by 10.50.149.233 with SMTP id ud9mr795322igb.92.1360646968792; Mon, 11 Feb 2013 21:29:28 -0800 (PST)
Sender chris@rebertia.com
In-Reply-To <CA+YdQ_7onfyrBgKTZHq0ZRS59iR8PyCi7FjL8VnDrfDLM-fsEA@mail.gmail.com>
References <CA+YdQ_7onfyrBgKTZHq0ZRS59iR8PyCi7FjL8VnDrfDLM-fsEA@mail.gmail.com>
Date Mon, 11 Feb 2013 21:29:28 -0800
X-Google-Sender-Auth nOhEwIvgN7c_EcNuaISzuiwKoRQ
Subject Re: call shell from python
From Chris Rebert <clp2@rebertia.com>
To contro opinion <contropinion@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Gm-Message-State ALoCoQlq7LkWJ6r6kYX9wHQ/qOdTzYgUy5agEgJ8P7Zpsq6c+oNcVczZCR0Qcg+w8sKeRlpNV2ib
Cc python-list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1686.1360646972.2939.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1360646972 news.xs4all.nl 6848 [2001:888:2000:d::a6]:56710
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:38729

Show key headers only | View raw


On Mon, Feb 11, 2013 at 9:13 PM, contro opinion <contropinion@gmail.com> wrote:
>>>> import os
>>>> os.system("i=3")
> 0
>>>> os.system("echo $i")
>
> 0
> how can i get the value of  i?

Your example is too heavily contrived for me to give a much more
specific/useful answer than "use the `subprocess` module":
http://docs.python.org/2/library/subprocess.html#using-the-subprocess-module

Of course, if all you want to do is manipulate environment variables,
then there's `os.environ`:
http://docs.python.org/2/library/os.html#os.environ

Good luck, my pseudonymous contrarian compadre.
– Chris

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


Thread

Re: call shell from python Chris Rebert <clp2@rebertia.com> - 2013-02-11 21:29 -0800

csiph-web