Setting Environment Variables
grante at visi.com
Wed Oct 20 22:11:25 CEST 2004
On 2004-10-20, Greg Lindstrom <greg.lindstrom at novasyshealth.com> wrote:
> I am running python 2.3. on an HP-9000 box running Unix and have a POSIX
> script that sets up my production environment. I would like to run the
> script from inside a python routine and pick up the environment variables
What do you mean by "pick up the environment variables"?
You do not have access to the environment of the child process, if that's
what you mean.
> but am having trouble getting it done. Suppose the script is called
> setprod. How can I call this from inside a python script then pick up the
> env's later in my program?
> I've tried os.system ('setprod') and os.system('. setprod'), but neither
> seemed to work.
You're going to have to change the script to print the data of interest to
stdout or stderr, and read it via a pipe. The child process can't change
the environment of the parent, and the parent can't read the environment of
Grant Edwards grante Yow! If I pull this SWITCH
at I'll be RITA HAYWORTH!! Or
visi.com a SCIENTOLOGIST!
More information about the Python-list