I'm having an issue when I export within my program. I'm getting the variable name, not the variable value. I have a configuration file (config.txt) that has the values of the variables set as so:
Code:
set -a
export ARCHIVEPOSourceDir="/interfaces/po/log /interfaces/po/data"
export ARCHIVEPRSourceDir="/interfaces/pr/log /interfaces/pr/data"
Then I have a shell script that I'm passing the configuration file and the interface name to as follows:
./CleanUpFiles.sh -C config.txt -P ARCHIVEPO
and here's the code in CleanUpFile.sh:
Code:
#!/usr/bin/ksh
PROG_NAME=`basename $0`
Usage ()
{
echo "Usage: $PROG_NAME -C ConfigFile(config.txt) -P ARCHIVE_Interface_Name"
exit 1
}
if [ $# -ne 4 ]
then
Usage
fi
while getopts C:P: Opt
do
case ${Opt} in
C) INTERFACE_CONFIG_FILE=${OPTARG}
;;
P) ARCHIVE_Interface_Name=${OPTARG}
;;
?) Usage
esac
done
. ${INTERFACE_CONFIG_FILE}
export SOURCEDIR=${ARCHIVE_Interface_Name}SourceDir
echo ${SOURCEDIR}
So I pass
ARCHIVEPO as the value for ARCHIVE_Interface_Name parameter to CleanUpFiles.sh. When the program executes:
export SOURCEDIR=${ARCHIVE_Interface_Name}SourceDir, my expectation was that it would give back the values, "/interfaces/po/log /interfaces/po/data", but instead I get back "ARCHIVEPOSourceDir". If I hard code the statement as:
export SOURCEDIR=${ARCHIVEPOSourceDir}, then I correctly get back the values, "/interfaces/po/log /interfaces/po/data". I need to be able to pass it as a parameter though, because this code is going to be reused by different interfaces. Any suggestions on a way around this?
Thanks,
Les...