Set an environment variable

Mike Meyer mwm at mired.org
Fri Oct 21 13:20:58 EDT 2005


Grant Edwards <grante at visi.com> writes:

> 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??

No. Are you being intentionally - never mind.

> And even Google knows the correct answer
>
> http://www.google.com/search?hl=en&lr=&q=python+set+environment+variable
>
> Follow the first hit.

The first hit is basically the solution presented above translated
from Unix to Windows: your python script writes the appropriate shell
commands into a file, then you get the command processor to process
that file. The Windows version carries this a step further by wrapping
it all up in a script to make it easy to run, but that's the only real
difference. Maybe the results order has changed since you looked?

Watch the recipe - I may add a Unix/sh solution.

      <mike

-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list