Command substitution and strings

Command substitution and strings

Post by Lovell Sco » Sun, 12 Aug 2001 13:16:13



I am new to this group & have a question that's been puzzling me for a
couple of days.  Here is the background.  I have a file that contains
a bunch of employee Id's, and a bunch of irrelevant stuff.  I have
written a ksh script to extract the employee's id when some data is
out of a pre-defined range, and send them an email message. Not all
employees get sent emails, just a few, so I'm setting them up as
variables in the script so there is only one file involved. Here is a
rough outline

#!/bin/ksh


#Employee ID1234 is out of specified range so assign it to variable
USER

USER=ID1234

#Now set up mail address
MailTo=`echo $\`echo $USER\``

...

echo the value I get $ID1234.  It seems to be treating $ID1234 as a
string, and not the value of the variable ID1234.  Any Ideas?

Thanks in advance,

 
 
 

Command substitution and strings

Post by Michael Wa » Sun, 12 Aug 2001 14:11:32



>#!/bin/ksh


>USER=ID1234
>MailTo=`echo $\`echo $USER\``


>echo the value I get $ID1234.  It seems to be treating $ID1234 as a
>string, and not the value of the variable ID1234.  Any Ideas?


USER=ID1234
eval MailTo=\$$USER

Posted and Emailed.

 
 
 

Command substitution and strings

Post by Lovell Sco » Mon, 13 Aug 2001 07:33:50




> >#!/bin/ksh


> >USER=ID1234
> >MailTo=`echo $\`echo $USER\``


> >echo the value I get $ID1234.  It seems to be treating $ID1234 as a
> >string, and not the value of the variable ID1234.  Any Ideas?


> USER=ID1234
> eval MailTo=\$$USER

> Posted and Emailed.

Thanks so much,
You da man
 
 
 

1. Command Substitution within Parameter Substitution?

Hi,

(GNU bash, version 2.05b.0(1)-release (i586-mandrake-linux-gnu).)

Is it possible, in the above version of BASH, to have (a) command
substitution(s) within (a) parameter substitution(s)?  I tried the
following in a BASH script:

gqview ${$( cat $HOME/mydisplay_return )#*\ }

and it didn't work.  The above code line was to execute GQview (an image
viewer) with the name of an image file that was stored, on it's own, in a
file called 'mydisplay_return', hence the 'cat' command to get at the image
file name.  The file name stored in the 'mydisplay_return' file was
prefixed with an identifying number followed by a space, hence the '#*\ '
parameter substitution to just leave the file name.  But it doesn't work.
What's wrong?

Yours,
Gary Hayward.

2. Solaris 2.7 and CiscoWorks 2000

3. Command substitution in rsh-command

4. linux + @home cable modem

5. Sed or awk substitution between strings

6. AIX Dynamic loading error: bad RLD 0; swig-c++ problem?

7. Substitution of control char in string

8. Shared Memory

9. Character string substitution for multiple files

10. Substitution of control chars in string

11. string substitution problem !!

12. Character string substitution with multiple files

13. Better Method than this for string substitution