Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: call from pthon to shell

Reply
Thread Tools

Re: call from pthon to shell

 
 
Jason Friedman
Guest
Posts: n/a
 
      02-17-2013
>>>> 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?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
call from pthon to shell Bqsj Sjbq Python 0 02-12-2013 05:38 AM
Re: call from pthon to shell Andrew Robinson Python 0 02-12-2013 01:00 AM
Re: How to pass shell variable to shell script from python Gerardo Herzig Python 1 02-27-2008 12:19 PM
Re: How to pass shell variable to shell script from python Christian Heimes Python 0 02-27-2008 10:53 AM
can I run unix shell command in the ModelSim shell? clinton__bill@hotmail.com VHDL 2 02-18-2005 10:04 PM



Advertisments