KSH question

From: Brewer, Edward <BREWERE_at_OD.NIH.GOV>
Date: Thu, 16 May 2002 11:54:21 -0400

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
Received on Thu May 16 2002 - 15:56:21 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:43 NZDT