I have an Oracle concurrent program that I'm passing a parameter to a unix shell script. An example value of the Oracle parameter is PO_TOP. The Oracle parameter represents the unix env var PO_TOP, meaning, on the unix side there is env var called PO_TOP (ex value: /oradev/apps/po/11.0.3/). My goal is to passed the Oracle parameter to the unix script and have it behave like the unix env var $PO_TOP.
Example of the code in the script.
ora_base_dir=$1
echo "ora_base_dir: "$ora_base_dir
cd $ora_base_dir
--
This fails with a directory does not exist
the echo displays "ora_base_dir: PO_TOP"
Here is some examples of the not so brilliant stuff that I have tried:
ora_base_dir=$$1
ora_base_dir=$\$1
ora_base_dir=${$1}
All failed.
Can you pass the name of a unix env variable to a unix shell script and then set a new unix var to the passed variable?
Note: I'm trying to avoid using
IF $1= 'PO_TOP' THEN
ora_base_dir=$PO_TOP
ELSIF $1 = 'FND_TOP' THEN
ora_base_dir=$FND_TOP.....etc
No. It is a parameter in an Oracle current program. The Oracle current program is a host script; In this case it will be a unix shell script. No sql or pl/sql is involved.
There are several ways to pass variables out of a shell script
one:
# write the variables
( echo "PO_TOP=/somedir/somewhere"
echo "UO_TOP=/anotherdir/somewhere"
) > env.txt
# if you want aboslutely everything in the environment
env > env.txt
# get the variables
while read cmd
do
eval $cmd
done < env.txt
Another way is to have script that needs to get the variables sourced by the script that creates them:
#!/bin/ksh
# i am the script that needs my env vars set
. ./otherscript.sh # this script creates them and does other work.
# i now have all my variables set
Thx, Jim. I don't think I'm clear on what I'm asking.
But basically, I'm passing the name of unix env var from my Oracle current program to the unix shell. To the shell script; it is $1 parameter.
If I do "echo $1". It will display PO_TOP. If I do "cd $1" it fails because the directory PO_TOP does not exist.
There is an unix env var call PO_TOP If do I "echo $PO_TOP". It will display "/oradev/apps/po/11.0.3". If I do "cd $PO_TOP" it works because the directory exists.
I'm bascially wanting to pass the name of unix env var to a shell script.