Hello all!
On my Solaris server, I currently have a menu in my .profile that gets executed when I log in. In this menu it asks a question and in response sources one of 3 files to set up environmental variables for my session.
I wanted to make a simple script that, when passed a parameter will source one of those 3 files which will set the environmental variables for my session and not just the script.
Here is what I have that works in the $HOME/.profile for my login:
I wanted to create a script called 'go' that can be passed the parameter "DEV", "SIT", or "UAT" that would source the appropriate "...autosys.ksh.XXX.server1" file which contains exported variables. Here is what I have so far:
...etc
What I'm seeing is that the exported variables are not sticking around when the 'go' script ends. How do you source a file from within a script and keep the exported variables in your session which were set within the sourced file?
Thanks for any help or insight you all can provide!
On my Solaris server, I currently have a menu in my .profile that gets executed when I log in. In this menu it asks a question and in response sources one of 3 files to set up environmental variables for my session.
I wanted to make a simple script that, when passed a parameter will source one of those 3 files which will set the environmental variables for my session and not just the script.
Here is what I have that works in the $HOME/.profile for my login:
Code:
read AutoSys_ENV
echo "You picked " $AutoSys_ENV
if [ "$AutoSys_ENV" = "DEV" ]
then
echo "Entering Dev Environment"
. /opt/autotree/autouser/autosys.ksh.dev.server1
elif [ "$AutoSys_ENV" = "SIT" ]
then
echo "Entering Sit Environment"
. /opt/autotree/autouser/autosys.ksh.sit.server1
elif [ "$AutoSys_ENV" = "UAT" ]
then
echo "Entering Uat Environment"
. /opt/autotree/autouser/autosys.ksh.uat.server1
else
echo "Invalid selection. "
fi
Code:
#! /usr/bin/ksh
# script to change between environments
#
if [[ $# -eq 0 ]]; then
echo "Give me dev, sit, or uat."
exit
fi
if [[ $# -gt 1 ]]; then
echo "What?"
exit
fi
if [ $1 = "dev" ]; then
. /opt/autotree/autouser/autosys.ksh.dev.server1
echo $1 ; exit
fi
if [ $1 = "sit" ]; then
. /opt/autotree/autouser/autosys.ksh.sit.server1
echo $1 ; exit
fi
What I'm seeing is that the exported variables are not sticking around when the 'go' script ends. How do you source a file from within a script and keep the exported variables in your session which were set within the sourced file?
Thanks for any help or insight you all can provide!