Environment variables

Gerrit Holl gerrit.holl at pobox.com
Thu Dec 2 14:55:12 EST 1999


jeff wrote:
> How do I set environment variables outside the python script?

os.environ["PATH"] = "/bin:/usr/bin:/usr/local/bin"

> Basicaly, I want to run a python script to set some environment variables,
> then be able to use them in the shell that had called the python script
> (after the script had completed).

Not possible. The Python script is started as a child. You can't set
environment variables for a parent.

> I need this for both Linux and NT/Win2k.

I don't know how it works on NT, but on Linux, you could output this,
like dircolors does:

export VARNAME=VARCONTENT;
export ANOTHERVARNAME=ANOTHERVARCONTENT

you could make a shell script:
#!/bin/sh

eval $(script.py $*)


Have fun!


-- 
"Open Standards, Open Documents, and Open Source"

  -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates)
  8:52pm  up  7:25, 14 users,  load average: 1.35, 1.19, 1.06




More information about the Python-list mailing list