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.

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
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 Sun, 27 Mar 2016 15:15:54 +0100
Lines 23
Message-ID <mailman.84.1459088163.28225.python-list@python.org> (permalink)
References <nd8mtk$hhb$1@aspen.stu.neva.ru> <85mvpkaun5.fsf@benfinney.id.au>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de b5NLG+l9HMB7YCF6ZHflAQ3hSZm3VtOWZ7ysQ+7ikoqg==
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:skip:s 10': 0.05; 'cc:addr:python-list': 0.09; 'subject:command': 0.09; 'output': 0.13; "'=',": 0.16; "'\\0'": 0.16; '2016': 0.16; 'cc:name:python list': 0.16; 'ends,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'something.': 0.16; 'subprocess': 0.16; 'wrote:': 0.16; '&gt;': 0.18; 'email addr:gmail.com&gt;': 0.18; 'changes': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'script': 0.25; "doesn't": 0.26; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'skip:e 30': 0.27; 'prints': 0.29; 'subject:update': 0.29; 'environment': 0.29; 'code': 0.30; 'file': 0.34; 'received:google.com': 0.35; 'too': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'subject:from': 0.39; 'subject:the': 0.39; 'skip:e 20': 0.39; 'some': 0.40; 'mar': 0.65; 'skip:\xe2 10': 0.70; 'skip:/ 30': 0.84; 'subject:source': 0.84; '(running': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=wbIoGeHhzQcDNwoDiSwLP5aAAqqzjUqdC/9oJbXEz0k=; b=n8MLdsAGiJU6alLTeydmxhQCtHVCHI1nhTn1O4OYlNgqEqcTgEFw6fGDv99Rbt/h/w 6Immc7YjjDNhcQL/4Z+rbxihDVsnxWgkL51hYV7tcCXz3hmaWtVEgZkaddztKv31Ettt /iZijmz8RWiRYfQl+Qsb9BvjWkfUDDjHGUwF/qBiM8KTO20UsvyUeK0X5VwG+K53TtAY CG12IUMfX487QFbQWxYZYIT047HKFyLyRjz3ZuGMrDte5DrkiB/3EC03i5HHmFdzj5zh qZy36JOteW5gOnkO0istO2MFqKzXmG5i/7eO452seLL6KtVGuUtgvc3/0i8XNgkqZMlN BYKg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=wbIoGeHhzQcDNwoDiSwLP5aAAqqzjUqdC/9oJbXEz0k=; b=OIGHwJ0tvYJTLgmvdNICQjk5umlTc05QnMmwTgWJ3ldC9yBMHzN7vcSM08DLGk+EbU GZ43xyzBXDryUiMLd2zWQ9qook+zPybePzOP+YQ2d/jLU5eMQ/nTnRZwXISXzlRo6zke 4p2LZQiJZokeaYvALMHkc7PyMXSHu61bCMD48zaLD1faCoauTS5R8h5E1g3K9OqwLaLJ WEKJjcMfZVF53tuOMTj5EQt5vtPpYL9OB1XAogMxNcy2Gudsj5mfkREOKcv9izMeipYS 2aJRe5GUF0/tVR7pdzSuHvnL5BBH/D3y8TwNXb8YJMed3dT19S+CADEFUuXBmjXnU6j4 sVlw==
X-Gm-Message-State AD7BkJIbxgUexgv6ecD7LiCWglmfJroj6rg4fS1bQhhj1u8TGpJYpBdqxhLvCMrR6rm8rTYxzk38y6JuIq6now==
X-Received by 10.112.181.196 with SMTP id dy4mr8672814lbc.42.1459088155538; Sun, 27 Mar 2016 07:15:55 -0700 (PDT)
In-Reply-To <85mvpkaun5.fsf@benfinney.id.au>
X-Content-Filtered-By Mailman/MimeDel 2.1.21
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:105843

Show key headers only | 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