subprocess with shared environment?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rowen

    #1

    subprocess with shared environment?

    I'd like to replace some shell scripts with Python, but one step of
    the script modifies my environment in a way that the subsequent steps
    require.

    A simple translation to a few lines of subprocess.call (...) fails
    because the first call modifies the environment, but the other lines
    don't see it.

    Is there a straightforward way to do this (without having to resort
    to writing some of it as a shell script)?

    -- Russell
  • Gabriel Genellina

    #2
    Re: subprocess with shared environment?

    En Mon, 17 Nov 2008 21:27:09 -0200, rowen <rowen@u.washin gton.edu>
    escribió:
    I'd like to replace some shell scripts with Python, but one step of
    the script modifies my environment in a way that the subsequent steps
    require.
    >
    A simple translation to a few lines of subprocess.call (...) fails
    because the first call modifies the environment, but the other lines
    don't see it.
    >
    Is there a straightforward way to do this (without having to resort
    to writing some of it as a shell script)?
    The first subprocess modifies *its* environment and dies - the
    modification is not seen by the caller process. I don't know of any way to
    modify parent's environment.
    You might "echo" the desired changes in the first subprocess, read them
    from the parent process and modify the environment that will be passed to
    later subprocesses. Perhaps someone else provides a more straightforward
    solution...

    --
    Gabriel Genellina

    Comment

    • alex23

      #3
      Re: subprocess with shared environment?

      On Nov 18, 9:27 am, rowen <ro...@u.washin gton.eduwrote:
      I'd like to replace some shell scripts with Python, but one step of
      the script modifies my environment in a way that the subsequent steps
      require.
      Is there a straightforward  way to do this (without having to resort
      to writing some of it as a shell script)?
      Perhaps using os.environ?


      Comment

      Working...