Re: call from pthon to shell

Discussion in 'Python' started by Jason Friedman, Feb 17, 2013.

  1. >>>> 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?
     
    Jason Friedman, Feb 17, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    5,771
    Jonathan Bromley
    Feb 18, 2005
  2. Christian Heimes
    Replies:
    0
    Views:
    611
    Christian Heimes
    Feb 27, 2008
  3. Gerardo Herzig
    Replies:
    1
    Views:
    1,106
    Philipp Pagel
    Feb 27, 2008
  4. Bqsj Sjbq

    call from pthon to shell

    Bqsj Sjbq, Feb 12, 2013, in forum: Python
    Replies:
    0
    Views:
    90
    Bqsj Sjbq
    Feb 12, 2013
  5. Andrew Robinson

    Re: call from pthon to shell

    Andrew Robinson, Feb 12, 2013, in forum: Python
    Replies:
    0
    Views:
    88
    Andrew Robinson
    Feb 12, 2013
Loading...

Share This Page