[Tutor] Changing (Unix) environment for python shell/popen()
commands
Scott W
wegster at mindcore.net
Sun Jan 23 20:14:38 CET 2005
Hey all.
I'm unfortunately stuck using python 1.5.2, primarily on Linux
currently, and have done the usual searching (on list, active state,
google), without luck.
I've got to shell out from my python code to execute a command, but
_must_ set the environment at the same time (or prior to execution). I
say must, because in this case the obvious answer of modifying the
command to be called or wrapping it with a shell script to set the
environment won't work/isn't going to happen.
I saw some comments about setting os.environ[<some shell var>], but
didn't seem to be seeing this work in subsequent calls using popen2().
Does anyone have a working piece of code setting some env variable
successfully prior to(or along with) calling popen2() (or friends).
Also, is there any way to get the called programs return code via
popen() (again, under python 1.5.2)?
I know this has been asked often enough, but once again, it seems I'm
left wanting for _good_ documentation under python (ie compared to man
pages, DevStudio Win32 docs, Linux info, Java docs, etc), including the
half dozen python books I own (great for some things, but no reference
whatsoever to other things that I'd think would warrant some coverage)..
Thanks,
Scott
More information about the Tutor
mailing list