RE: unix shell script question

2003-07-15 Thread Hitchman, Peter
Hi,
This works in ksh:

DBNAME=PROD 
LINE_PROD=500   
OTHER=\${LINE_${DBNAME}}
eval echo $OTHER

Regards

Pete

[END]

-Original Message-
Sent: 15 July 2003 11:35
To: Multiple recipients of list ORACLE-L


Hi List,

The requirement is as follows:

DBNAME=PROD ( 'DBNAME' variable contains value 'PROD' )

LINE_PROD=100 ( 'LINE_PROD' variable contains value 100 )

Now I want to echo the LINE_PROD variable using DBNAME variable.
e.g 
echo ${LINE_${DBNAME}} should return 100.

Is this possible and if yes, how ? I tried some ways but couldn't find any
way.

Regards,
~Dilip



Get Your Private, Free E-mail from Indiatimes at http://email.indiatimes.com

 Buy The Best In BOOKS at http://www.bestsellers.indiatimes.com

Bid for for Air Tickets @ Re.1 on Air Sahara Flights. Just log on to
http://airsahara.indiatimes.com and Bid Now !

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Dilip
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).


This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com


__

The information contained in this email is confidential and 
intended only for the use of the individual or entity named 
above. If the reader of this message is not the intended 
recipient, you are hereby notified that any dissemination, 
distribution, or copying of this communication is strictly 
prohibited. Thomson Scientific will accept no responsibility 
or liability in respect to this email other than to the addressee. 
If you have received this communication in error, please 
notify us immediately via email: [EMAIL PROTECTED]
__
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Hitchman, Peter
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).


RE: unix shell script question

2003-07-15 Thread Stephen Lee

Something else for people who are bored:
If I may ASS-U-ME that your ultimate goal is to have variables like:

LINE_THIS
LINE_THAT
LINE_THE_OTHER_THING

and you want to be able to change what is after the LINE part, if you have
genuine ksh93, and you like playing around with scripting stuff, then you
can try playing around with associative arrays.
For example:

LINE=([THIS]='ABC' [THAT]='XYZ' [THE_OTHER_THING]='HELLO WORLD')
X='THE_OTHER_THING'
echo ${LINE[$X]}
HELLO WORLD
X='THIS'
echo ${LINE[$X]}
ABC
X='THAT'
echo ${LINE[$X]}
XYZ

I think you must define the associative array as a single command; i.e. you
can't do
LINE=([THIS]='ABC')
LINE=([THAT]='XYZ')
because you will only have ${LINE[THAT]}

Note that, as far as I know, this stuff works only with ksh93.  Ksh88 is
probably much more predominant on non-Linux, and I think pdksh (public
domain ksh) -- which is useless for scripting -- shows up on Linux.  But you
can download and build ksh93.  Make sure you put the (){}[] characters in
the right places.

> -Original Message-
> 
> Hi List,
> 
> The requirement is as follows:
> 
> DBNAME=PROD ( 'DBNAME' variable contains value 'PROD' )
> 
> LINE_PROD=100 ( 'LINE_PROD' variable contains value 100 )
> 
> Now I want to echo the LINE_PROD variable using DBNAME variable.
> e.g 
> echo ${LINE_${DBNAME}} should return 100.
> 
> Is this possible and if yes, how ? I tried some ways but 
> couldn't find any way.
> 
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Stephen Lee
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).