Setting UNIX environment with a Python script

Cameron Hutchison camh at zip.com.au
Tue Mar 12 17:30:40 EST 2002


On Tue, 12 Mar 2002 13:25:57 +1100, Grant Edwards wrote:

> In article <pan.2002.03.12.11.14.20.48643.1649 at zip.com.au>, Cameron
> Hutchison wrote:
> 
>> What you need to do instead is have your python program print on stdout
>> the name of the ora_env file to source. Then you invoke your python
>> script from your shell login script like this (bourne style shell
>> assumed):
>> 
>> eval "source ora_env.`get_ora_name`"
> 
> Another common method is to have your Python program write the shell
> commands to stdout, then execute them with something like
> 
> eval `myPythonProgram`
> 

While that would work fine, I dont think it's a terribly good idea. I
think it would be cleaner to keep the shell syntax in a shell script and
avoid having the python program assume the scripting environment it is
returning to.



More information about the Python-list mailing list