KSH question

From: Brewer, Edward (BREWERE@OD.NIH.GOV)
Date: Thu May 16 2002 - 11:54:21 EDT


Admins,

I have run into a problem concerning ksh. I need to call up the value of a
variable into another variable but must define the variable with variables.
Here is an example of what I am referring to.

Let's say I have the following variables
SYSTEM_ABCD=1234
EXT=abcd

I need to

command 1234

where SYSTEM_ABCD is defined by EXT

SYSTEM_$EXT

I could hard code the value, but I want it to read EXT to find SYSTEM_$ABCD
because I have other values for other systems such as SYSTEM_EFGH=5678

so,
I did the following

Variable list.....
SYSTEM_ABCD=1234
EXT=abcd
Variable list ends ...

INST=`echo EXT | tr -s '[:lower:]' '[:upper:]'` # convert to uppercase
PASS = `echo '$SYSTEM_'$INST`
echo $PASS
command $PASS

the result is that echo $PASS gives $SYSTEM_ABCD
and the command fails, because it pass $SYSTEM_ABCD instead of 1234.

I have tried several tricks and combinations and they have had all of the
same results. I know I have done this in the past but I can't figure out
how to make the shell interpret the string instead of treating it literal.

TIA,

Lee Brewer



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:48:41 EDT