Ahh. I had seen an example in the o'reilly text 'learning the bash shell' that 
made it appear variable substitution in case was valid, but considering
they were using $PWD as the variable, indeed it would be the entire string.

I'll try the loop in the morning.  It would be nice if case DID work that way 
though.





             "Fargusson.Alan" <[EMAIL PROTECTED]>
             Sent by: Linux on 390 Port
             <LINUX-390@VM.MARIST.EDU>                                          
                                                                   To
                                                                     
LINUX-390@VM.MARIST.EDU
                                                                                
                                                                   cc
             09/06/2007 04:23 PM
                                                                                
                                                              Subject
                                                                     Re: I am 
missing something basic with bash scripting.
                            Please respond to
               Linux on 390 Port <LINUX-390@VM.MARIST.EDU>








The problem is that bash takes cooked_list as a single token in the case 
statement.  It matches the entire list of systems, and not each member of the
list.  I don't know of any way around this.  You will probably need to do 
another for loop on raw_list and check for a match in the loop.

-----Original Message-----
From: Linux on 390 Port [mailto:[EMAIL PROTECTED] Behalf Of
James Melin
Sent: Thursday, September 06, 2007 1:53 PM
To: LINUX-390@VM.MARIST.EDU
Subject: I am missing something basic with bash scripting.


I am trying to get away from hard coded server names in a script using case for 
valid name check

This works but is not good because as soon as you add a new server to the NFS 
mountpoint list the script this is from has to be changed.

case $target_system in
  abinodji | calhoun | itasca | nokomis | pepin | phalen | vadnais | bemidji | 
millpond | mudlake | terrapin | hadley | hyland ) parm_1="valid";;
esac


So I tried several variants of this:

space=" "
delim=" | "
raw_list=`ls /clamscan/servers`     #read list of mountpoints
cooked_list=$(echo $raw_list | sed -e "s:$space:$delim:g") #replace space with 
case-happy delimiters
echo "Raw list = "$raw_list
echo "cooked list = "$cooked_list
case $target_system in
  $cooked_list ) parm_1="valid" ;;
esac

But even though the display of 'cooked_list' seems to be what I want it to be, 
this never returns a match.

Anyone see where I missed the turnip truck on this?

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to