The profile of the user is empty. Then before I run the script I want I run a parameter file that populates the variables for oracle.
ORACLE_HOME
ORACLE_BASE
ORACLE_SID
PATH
etc ...
But it seems that these variables are not making it to the shell I am in because when I do an echo on these variable I get nothing.
We are in the korn shell and the parameter file is a special file .myvars.
Does anyone know why I am not getting the variable values for the program I run after this parameter file gets run. I am exporting the variables in the .myvars file???
#!/bin/ksh
echo "ORACLE_HOME->[${ORACLE_HOME}]"
. .myvars
echo "ORACLE_HOME->[${ORACLE_HOME}]"
/mydir>#!/bin/ksh
/mydir>echo $ORACLE_HOME
/mydir>./.myvars
/mydir>echo $ORACLE_HOME
I get nothing before or after?
.myvars contents (I changed the dir names for this post)
#!/bin/ksh
ORACLE_HOME=/oracle_home
export ORACLE_HOME
ORACLE_BASE=/oracle_Base
export ORACLE_BASE
ORACLE_SID=MYDB
export $ORACLE_SID
ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export ORA_NLS33
PATH=.:/usr/bin:/usr/sbin:/etc:$ORACLE_HOME/bin:/bin:/opt/bin:/usr/ccs/bin
export PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:/usr/openwin/lib:/usr/dt/lib
export LD_LIBRARY_PATH
export LOADER_HOME=$ORACLE_HOME/bin
TNS_ADMIN=$ORACLE_HOME/network/admin
export TNS_ADMIN
You can simply include that myvars file which contains varialble information as,
. ./myvars
For Example,
/tmp/myvars contains
test="hai gm"
test1="bye"
#!/bin/ksh
. /tmp/myvars
echo $test
echo $test1
Try this. did you get that?
pay attention to my original posting AND to the way '.myvars' were called!
#!/bin/ksh
echo "ORACLE_HOME->[${ORACLE_HOME}]"
. .myvars
echo "ORACLE_HOME->[${ORACLE_HOME}]"
use echo $$
to see whether the script is running in the parent shell or child shell.
If run the script in the parent shell ... you can retain the env variables
you are exporting in the script.
. ./x.sh makes x.sh to run in the parent shell.
$ unset a
$
$ ./x.sh
20344
$ echo $$
53178
$ . ./x.sh
53178
$ cat x.sh
export a="hello world "
echo $$
$
Sometimes it's hard to see the forrest for the trees.
Just to clarify:
. ./myvars
Notice the space after the first period, "."? This causes the envornment variables set in myvars to stick so to speak.
Thomas