[Tutor] trouble setting the environment

Ertl, John john.ertl at fnmoc.navy.mil
Thu Apr 21 22:28:57 CEST 2005


Kent,

Good idea except that the environment that needs to be set depends on the
answers to some of the input that I get in the Python program.   Nothing is
ever easy here.

Thanks for the ideas.

John Ertl 

-----Original Message-----
From: Kent Johnson [mailto:kent37 at tds.net]
Sent: Thursday, April 21, 2005 13:20
Cc: tutor at python.org
Subject: Re: [Tutor] trouble setting the environment

Ertl, John wrote:
> All,
>
> I have program and init I want to "source" a .ksh file to set some
> environment variables and then use those variables in my program.
>
> Is this possible? I vaguely remember something about the system env and
the
> interpreters env being separate after the interpreter starts up.

What about making a shell file that sources your ksh file, then starts
python?

Kent

>
> For instance if I have a .ksh file called envSet.ksh:
>
> #!/bin/ksh
>
> unset OPSBIN
>
> export OPSBIN=/u/ops/bin
>
> ---end --
>
> Then
> 
>
>>>>os.system(". envSet.ksh")
>
> 0
>
>>>>os.getenv("OPSBIN")
>>>>
>
>
> What is the 0.  I know that I can set the env using Python but all of the
> correct env are in the .ksh files maintained by others.  I would hate to
> have to take the .ksh and tread each line and if it is an export turn that
> into a python  os.environ statement.
>
> Any ideas.
>
> Thanks
>
> John
>       
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>

_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list