Set an environment variable

Steve Holden steve at holdenweb.com
Fri Oct 21 07:40:37 EDT 2005


Christian wrote:
> Steve Holden wrote:
> 
> 
>>::::::::::::::
>>one.py
>>::::::::::::::
>>import os
>>os.environ['STEVE'] = "You are the man"
>>os.system("python two.py")
>>print "Ran one"
>>::::::::::::::
>>two.py
>>::::::::::::::
>>import os
>>print "STEVE is", os.environ['STEVE']
>>print "Ran two"
>>[sholden at headrat tmp]$ python one.py
>>STEVE is You are the man
>>Ran two
>>Ran one
>>[sholden at headrat tmp]$
>>
>>Hope this helps.
>>
>>regards
>> Steve
> 
> 
> Thanks Steve, you're quite right, you are the man. And thanks to all the 
> rest of you for your kind help and patient understanding. I have learned 
> quite a lot and is about to consider my self advanced to the status of 
> Python newbie.
> 
> So here is my final question:
> Do I call the .sh script with a .py script like this:
> 
> os.system("/path/to/the/script/startupscript.sh")

Time you answered your own questions by trying things at the interactive 
interpreter prompt!

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list