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


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

how to call shell?

Started bycontro opinion <contropinion@gmail.com>
First post2013-02-12 13:12 +0800
Last post2013-02-11 21:43 -0800
Articles 2 — 2 participants

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


Contents

  how to call shell? contro opinion <contropinion@gmail.com> - 2013-02-12 13:12 +0800
    Re: how to call shell? Tim Roberts <timr@probo.com> - 2013-02-11 21:43 -0800

#38725 — how to call shell?

Fromcontro opinion <contropinion@gmail.com>
Date2013-02-12 13:12 +0800
Subjecthow to call shell?
Message-ID<mailman.1682.1360645931.2939.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

>>> import os
>>> os.system("i=3")
0
>>> os.system("echo $i")

0
>>>
why i can't get the value of i ?

[toc] | [next] | [standalone]


#38730

FromTim Roberts <timr@probo.com>
Date2013-02-11 21:43 -0800
Message-ID<1gljh819iupmdr555ni58b6htoi9l3a5u8@4ax.com>
In reply to#38725
contro opinion <contropinion@gmail.com> wrote:
>
>>>> import os
>>>> os.system("i=3")
>0
>>>> os.system("echo $i")
>
>0
>>>>
>why i can't get the value of i ?

Each invocation of os.system creates a brand new shell that starts, runs,
and terminates.  Your first command adds a variable "i" to the environment
for that shell, but the variable is deleted when the shell procsess
terminates.
-- 
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

[toc] | [prev] | [standalone]


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


csiph-web