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


Groups > comp.lang.python > #39015

Re: call from pthon to shell

References <1360647500.45284.YahooMailNeo@web160602.mail.bf1.yahoo.com>
Date 2013-02-17 00:00 -0700
Subject Re: call from pthon to shell
From Jason Friedman <jsf80238@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1882.1361084432.2939.python-list@python.org> (permalink)

Show all headers | View raw


>>>> import os
>>>> os.system("i=3")
> 0
>>>> os.system("echo $i")
>
> 0
>
> why i can not get the value of i?

Each call to os.system starts a new shell.  Think about what would
happen if you opened a terminal and typed:

$ i=3

Then, close that terminal and open a new one.  You would not be surprised that

$ echo $i

returns nothing.

And, as mentioned by Andrew, even absent that problem os.system is not
the way to obtain the data you are looking for.

I realize this is now 5 days after you posted ... what were you
ultimately attempting to accomplish?

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


Thread

Re: call from pthon to shell Jason Friedman <jsf80238@gmail.com> - 2013-02-17 00:00 -0700

csiph-web