Set an environment variable

Grant Edwards grante at visi.com
Fri Oct 21 16:34:09 CEST 2005


On 2005-10-21, Christian <christian at spam.not> wrote:
>> 
>> The closest thing you can do is that:
>> 
>> -myScript.py--------------------------------------
>> print 'export MY_VARIABLE=value'
>> --------------------------------------------------
>> 
>> -myScript.sh--------------------------------------
>> python myScript.py > /tmp/chgvars.sh
>> . /tmp/chgvars.sh
>> --------------------------------------------------

Bullshit.  Are people being intentionally misleading??

> Can I write a .py script that calls a .sh script that executes the 
> export command and then calls another .py script (and how would the 
> first .py script look)?

Good grief, that's ugly.  Just use os.putenv().

> That would be much more what is my basic problem.

And even Google knows the correct answer

http://www.google.com/search?hl=en&lr=&q=python+set+environment+variable

Follow the first hit.

-- 
Grant Edwards                   grante             Yow!  TONY RANDALL! Is YOUR
                                  at               life a PATIO of FUN??
                               visi.com            



More information about the Python-list mailing list