Setting environment

Setting environment

Post by Dale DeReme » Wed, 17 Jul 2002 23:22:53



I am using AIX 4.3.3 and the korn shell. I have a script that provides a
menu to our operators. When a selection is made, a set of environment
variables are set, by calling another script. For example, selection "2" I
use the case function to come to the action . /home/user/setenv1  This works
fine in the script, but when I exit, the environment reverts back to the
original state, (what it was before the menu was run). If I put that same
command in a one line script, that is, testt.sh contains .
/home/user/setenv1  This sets the environment and it stays set even when the
script is done. I'd appreciate any advice.
 
 
 

Setting environment

Post by Alois Steind » Wed, 17 Jul 2002 23:34:05



> I am using AIX 4.3.3 and the korn shell. I have a script that provides a
> menu to our operators. When a selection is made, a set of environment
> variables are set, by calling another script. For example, selection "2" I
> use the case function to come to the action . /home/user/setenv1  This works
> fine in the script, but when I exit, the environment reverts back to the
> original state, (what it was before the menu was run). If I put that same
> command in a one line script, that is, testt.sh contains .
> /home/user/setenv1  This sets the environment and it stays set even when the
> script is done. I'd appreciate any advice.

Hello,
well, the best advice is: Please look into the FAQ for
comp.unix.questions.

That treats this problem and many more which you might encounter some
day.

Good luck
Alois

 
 
 

Setting environment

Post by Dale DeReme » Thu, 18 Jul 2002 00:53:13


Forgive my ignorance, but where do I find the FAQ?



> > I am using AIX 4.3.3 and the korn shell. I have a script that provides a
> > menu to our operators. When a selection is made, a set of environment
> > variables are set, by calling another script. For example, selection "2"
I
> > use the case function to come to the action . /home/user/setenv1  This
works
> > fine in the script, but when I exit, the environment reverts back to the
> > original state, (what it was before the menu was run). If I put that
same
> > command in a one line script, that is, testt.sh contains .
> > /home/user/setenv1  This sets the environment and it stays set even when
the
> > script is done. I'd appreciate any advice.

> Hello,
> well, the best advice is: Please look into the FAQ for
> comp.unix.questions.

> That treats this problem and many more which you might encounter some
> day.

> Good luck
> Alois

 
 
 

Setting environment

Post by Hans-Joachim Ehler » Thu, 18 Jul 2002 05:08:27




Quote:> Forgive my ignorance, but where do I find the FAQ?

http://www.faqs.org/

To your problem

parse the file with ". MyPath/MyScript" - "dot space ..."

Hm , after rereading your message i would say:
It works as designed.

Hajo

 
 
 

Setting environment

Post by Mohi » Thu, 18 Jul 2002 15:00:22



> I am using AIX 4.3.3 and the korn shell. I have a script that provides a
> menu to our operators. When a selection is made, a set of environment
> variables are set, by calling another script. For example, selection "2" I
> use the case function to come to the action . /home/user/setenv1  This works
> fine in the script, but when I exit, the environment reverts back to the
> original state, (what it was before the menu was run). If I put that same
> command in a one line script, that is, testt.sh contains .
> /home/user/setenv1  This sets the environment and it stays set even when the
> script is done. I'd appreciate any advice.

Hi,

Send the script. I'll make it work.

Mohit Anchlia

 
 
 

Setting environment

Post by Ross » Fri, 19 Jul 2002 00:07:11



> I am using AIX 4.3.3 and the korn shell. I have a script that provides a
> menu to our operators. When a selection is made, a set of environment
> variables are set, by calling another script. For example, selection "2" I
> use the case function to come to the action . /home/user/setenv1  This works
> fine in the script, but when I exit, the environment reverts back to the
> original state, (what it was before the menu was run). If I put that same
> command in a one line script, that is, testt.sh contains .
> /home/user/setenv1  This sets the environment and it stays set even when the
> script is done. I'd appreciate any advice.

Dotting a script and running a script are entirely separate cases.
The rule to remember is that a child cannot modify a parent's
environment.  Your get-out-of-jail-free card is the "eval" command,
q.v.

regards,
Ross

--
Glendower: I can call spirits from the vasty deep.
Hotspur:   Why, so can I, or so can any man;
           But will they come when you do call for them?

 
 
 

Setting environment

Post by Norman Levi » Fri, 19 Jul 2002 00:07:58



| I am using AIX 4.3.3 and the korn shell. I have a script that provides a
| menu to our operators. When a selection is made, a set of environment
| variables are set, by calling another script. For example, selection "2" I
| use the case function to come to the action . /home/user/setenv1  This works
| fine in the script, but when I exit, the environment reverts back to the
| original state, (what it was before the menu was run). If I put that same
| command in a one line script, that is, testt.sh contains .
| /home/user/setenv1  This sets the environment and it stays set even when the
| script is done. I'd appreciate any advice.

If you are running a script and intend to have it change variables in
the current environment, you must 'source' it (that is,
do not
bozo
but
. /path/bozo
where the dot is 'sourcing' the file bozo.

Else, bozo runs in a subshell so things it sets are never seen at the
higher level.
norm