0

here is the thing i am trying to do . I have a system variable called $OOCEA_INCOMING_READY, I want to be able to construct this variable name inside the script and use it. I am passing part of the variable name OOCEA as parameter but i am not able to use this variable after constructing the name , see below :
----------------- code a.sh ----------------------------------------------
#!/usr/bin/ksh
set -x
AGENCY=$1
AGENCY_CODE=$2
FILE_TYPE=$3
#
echo \$${AGENCY}_INCOMING_READY
ls \$${AGENCY}_INCOMING_READY
ls $OOCEA_INCOMING_READY
exit
-------------------------------------------------------------------------


./a.sh OOCEA 05 ITRN

+ AGENCY=OOCEA
+ AGENCY_CODE=05
+ FILE_TYPE=ITRN
+ echo $OOCEA_INCOMING_READY <<<< does not work
$OOCEA_INCOMING_READY
+ ls $OOCEA_INCOMING_READY <<<< does not work
$OOCEA_INCOMING_READY: No such file or directory
+ ls /u02/oocea/incoming/ready <<< this works if i hard code the
ITRN_20090430_0030.ZIP ITRN_20090430_1230.ZIP variable name .
+ exit

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by masijade
0

Check out the "eval" command.

Edit: I.E.

eval "echo \$${AGENCY}_INCOMING_READY"

Edited by masijade: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.