[Tutor] trouble setting the environment
alan.gauld at freenet.co.uk
Thu Apr 21 23:19:06 CEST 2005
> Is this possible? I vaguely remember something about the system env
> interpreters env being separate after the interpreter starts up.
When you execute another process it gets its own environment.
When it dies its environment dies with it. You can get round
this in your case by forking the child process and reading the
environment variables and writing them back via a pipe to the
original program - messy but it works!
> >>> os.system(". envSet.ksh")
> >>> os.getenv("OPSBIN")
> What is the 0.
The return value from os.system(). It basically means the command
ran without errors. Not too useful normally. popen() is better
if you want to read the output (it basically does the fork/pipe
thing automagically for you) So if you popen a script that runs
your ksh file then prints the environment variables, you can read
them into your program...
Author of the Learn to Program web tutor
More information about the Tutor