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


Groups > comp.lang.python > #105843

Re: Calling the source command from subprocess.popen to update the os.environ.

From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Newsgroups comp.lang.python
Subject Re: Calling the source command from subprocess.popen to update the os.environ.
Date 2016-03-27 15:15 +0100
Message-ID <mailman.84.1459088163.28225.python-list@python.org> (permalink)
References <nd8mtk$hhb$1@aspen.stu.neva.ru> <85mvpkaun5.fsf@benfinney.id.au>

Show all headers | View raw


On 27 Mar 2016 17:01, "Ben Finney" <ben+python@benfinney.id.au> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > I use the following code the update the os.environ:
> >
> > import os
> > from subprocess import check_output
> >
> > # POSIX: name shall not contain '=', value doesn't contain '\0'
> > output = check_output("source /home/werner/env-intel-toolchains.sh;
> >          env -0", shell=True, executable="/bin/bash")
>
> That will start a new process (running ‘/bin/bash’), then execute some
> commands from a script file in that process.
>
> When that new process ends, any changes in its environment also
> disappear.

...unless the subprocess prints them out or something.

I think you skimmed the code and question a little too quickly.

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


Thread

Calling the source command from subprocess.popen to update the os.environ. Hongyi Zhao <hongyi.zhao@gmail.com> - 2016-03-27 13:24 +0000
  Re: Calling the source command from subprocess.popen to update the os.environ. Ben Finney <ben+python@benfinney.id.au> - 2016-03-28 00:59 +1100
  Re: Calling the source command from subprocess.popen to update the os.environ. Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-03-27 15:15 +0100
  Re: Calling the source command from subprocess.popen to update the os.environ. Chris Angelico <rosuav@gmail.com> - 2016-03-28 01:34 +1100
  Re: Calling the source command from subprocess.popen to update the os.environ. Hongyi Zhao <hongyi.zhao@gmail.com> - 2016-03-27 23:40 +0000

csiph-web