Re: Adding environment variables to bash.

2008-09-11 Thread Craig Allen
On Sep 11, 10:25 am, nntpman68 <[EMAIL PROTECTED]> wrote: > >> doesn't exactly work for Python scripts, though: > > >> $ cat env.py > >> #!/usr/bin/env python > >> import os > >> os.environ["TEST"] = "hello" > > >> $ . ./env.py && env | grep TEST > >> import: unable to open X server `'. > >> bash:

Re: Adding environment variables to bash.

2008-09-11 Thread nntpman68
doesn't exactly work for Python scripts, though: $ cat env.py #!/usr/bin/env python import os os.environ["TEST"] = "hello" $ . ./env.py && env | grep TEST import: unable to open X server `'. bash: os.environ[TEST]: command not found There's two options for the desperate ones. 1. Assumin

Re: Adding environment variables to bash.

2008-09-11 Thread John Lawrence
> > doesn't exactly work for Python scripts, though: > True, but you can use it in the following (admittedly messy) way: jl> cat setenv.sh /usr/bin/env python $@ . ./settmp rm settmp jl> cat env.py #!/usr/bin/python command = "export TEST='hello'\n" open('settmp', 'w').write(command) jl> . sete

Re: Adding environment variables to bash.

2008-09-11 Thread Fredrik Lundh
John Lawrence wrote: You can make a command use the current shell though if you use the '.' command e.g.: jl > cat env.sh export TEST='hello' jl > ./env.sh && env | grep TEST #Doesn't set TEST in parent shell jl > . ./env.sh && env | grep TEST #Adding '. ' before the comman

Re: Adding environment variables to bash.

2008-09-11 Thread John Lawrence
> > when a process starts, it gets a *copy* of the parent's environment. it > can modify that copy, but it cannot modify the variables in the parent. You can make a command use the current shell though if you use the '.' command e.g.: jl > cat env.sh export TEST='hello' jl > ./env.sh && env |

Re: Adding environment variables to bash.

2008-09-11 Thread Fredrik Lundh
aditya shukla wrote: Can i add any environment variable to bash from my python script? so that when i use env command then i can see that environment variable. not if you run the script from the shell. when a process starts, it gets a *copy* of the parent's environment. it can modify that c

Adding environment variables to bash.

2008-09-11 Thread aditya shukla
Hello folks Can i add any environment variable to bash from my python script? so that when i use env command then i can see that environment variable. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list