Operating System - HP-UX
1826474 Members
4002 Online
109692 Solutions
New Discussion

looking for a simple way to organize envs on our unix box...

 
SOLVED
Go to solution
Manuel Contreras
Regular Advisor

looking for a simple way to organize envs on our unix box...

would like to standardize how we set envs on our unix box, so I thought a menu would be a great way to accomplish this.

The problem I'm experiencing, is the value is set...but ONLY during the time the menu is initiated.

please see below:
> /home/is/bin/r12MENU.sh
**================================================================**
** to Set your environment, select one of the following: **
** 1.) DEVSID - Development Environments **
** 2.) UATSID - CRP2/UAT Environments **
** 3.) GLDSID - GOLD Environments **
** 4.) APPSSID - PROD Environments **
** e.) EXIT this menu **
**================================================================**


** Enter your response (1, 2, 3, 4 or [e]): 1

**=========================================================**
** You have chosen DEVSID - Development Environments **
** **
** your environment will now be set... **
**=========================================================**
devsid



the devsid you see above is an ECHO within the menu script on oracle_sid.
so I know it's setting the correct env, but only during the running of the menu-script.

If I perform an echo from command line...it's set to whatever was defined before running the menu.

If I run the individual scripts from CL, it sets my env correctly...so it's not the individual env scripts.

any assistance would be appreciated,
manny
3 REPLIES 3
OldSchool
Honored Contributor
Solution

Re: looking for a simple way to organize envs on our unix box...

"If I run the individual scripts from CL, it sets my env correctly...so it's not the individual env scripts." Doubtful. How are you "running" them?

As for the remainder of the problem:

that is the normal behaviour...you are altering the ENV of the child process, so the changes "disappear" when the child ends.

you need to "dot-in" (source) both the menu script AND the scripts run by the menu to change the environment.

ie:
. /home/is/bin/r12MENU.sh


and within r12MENU.sh each selected item must be "sourced" as well

Alternatively, one *might*, for each "selection":
a) Set environment
b) execute a "new" shell. Puts you in a sub-shell with the "correct" environment
c) exit the sub-shell, which should return you to the menu script.

Can't vouch for the later, as I've not tried it.
Steven E. Protter
Exalted Contributor

Re: looking for a simple way to organize envs on our unix box...

Shalom,

1) Figure out what is common to all environments.

2) Rather than have a menu required for login which can mess up the users if they want to automate some of their work, have a little script that pops up. User types myenv. Then the menu comes up and sources one of the 4 environment files. Set up a default or set a single variable for each user with the best guess for what they do. if [ "$USENV" == "dev" ] then . devenv

Something like that.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Manuel Contreras
Regular Advisor

Re: looking for a simple way to organize envs on our unix box...

referencing the menus and env scripts with ". menu.sh" worked like a charm.

cross this one off the list :)

thanks guys