Embedding setenv
Bolton, Gawain [ADC:4808:EXCH]
boltong at europem01.nt.com
Thu Feb 22 05:23:13 EST 2001
O'Rourke Clodagh-corour01 wrote:
> Hi all,
>
> I was wondering does anyone know how to embed the setenv command in python.
> I've tried os.system("setenv VARIABLE value")
> But I get: sh: setenv: not found
>
> Any ideas?
>
> Thanks,
> Clodagh O Rourke
Yeah try:
import os
os.environ[name] = value
Note that this will set the environment variable for the current process.
Your os.system() call did not work firstly because "setenv" is a csh command
and os.system() spawned a plain old shell session. Secondly, this is the
wrong approach because the environment variable will be set only for the
sub-process created by the system() command. Thirdly, this approach is very
inefficient.
Gawain
--
-------------------------------------------------------------------------------
Gawain Bolton | E-mail: boltong at nortelnetworks.com
Section 4808 |
UMTS Development |
Nortel Networks | Voice: ESN 579-3763 +33 1.39.44.37.63
Guyancourt, France | FAX: ESN 579-3009 +33 1.39.44.30.09
-------------------------------------------------------------------------------
More information about the Python-list
mailing list