473,395 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
Nov 17 '08 #1
2 2712
En Mon, 17 Nov 2008 21:27:09 -0200, rowen <ro***@u.washington.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

Nov 18 '08 #2
On Nov 18, 9:27*am, rowen <ro...@u.washington.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?

http://www.python.org/doc/2.5.2/lib/os-procinfo.html
Nov 18 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Sigfried Manner | last post by:
Hello NG! I have following situation: c-prg | webprg "c-prg" is a small c-programm which reads data from an fastCgi-Server and writes them to stdout. The stdout is piped into webprg....
0
by: John Dalberg | last post by:
I am trying to lock down file access of some sites in a shared hosting environment so that different users can only access their own site's directory with their asp.net code. However there's a...
1
by: Michelle Stone | last post by:
I am exploring the technical possibilities and the legal issues in using Visual Studio.NET in a shared environment. I would like to know if it is possible/legal to have Visual Studio.NET on a server...
0
by: Michael Johnson Sr. | last post by:
Is there any good documents on this. I am looking to secure the resources of the machine as well as standard security of the contents while having shared users running ASP.NET applications.
2
by: Gerard Flanagan | last post by:
Hello, I have a third party shell script which updates multiple environment values, and I want to investigate (and ultimately capture to python) the environment state after the script has run....
1
by: Marko Rauhamaa | last post by:
This tiny program hangs: ======================================================================== #!/usr/bin/env python import subprocess a = subprocess.Popen('cat',shell = True,stdin =...
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
1
by: replysonika | last post by:
Hello, I run a Java app with subprocess from Python script. This python script is called from another Python Wrapper. python = subprocess.Popen(, stdout=subprocess.PIPE,...
0
by: Albert Hopkins | last post by:
On Mon, 2008-11-17 at 15:27 -0800, rowen wrote: subprocess.call = call(*popenargs, **kwargs) Run command with arguments. Wait for command to complete, then return the returncode attribute. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.