> -----Original Message-----
> From: Linux on 390 Port [mailto:[EMAIL PROTECTED] On
> Behalf Of James Melin
> Sent: Thursday, September 06, 2007 3:53 PM
> To: [email protected]
> 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?
I cannot answer your question. Perhaps the "case" does not allow the
delimiters with a shell variable? I don't know. the following should
work in place of the "case" construct, however. It has more overhead,
but should work.
echo ${raw_list} | egrep -q "\<${target_system}\>" && parm_1="valid"
--
John McKown
Senior Systems Programmer
HealthMarkets
Keeping the Promise of Affordable Coverage
Administrative Services Group
Information Technology
The information contained in this e-mail message may be privileged
and/or confidential. It is for intended addressee(s) only. If you are
not the intended recipient, you are hereby notified that any disclosure,
reproduction, distribution or other use of this communication is
strictly prohibited and could, in certain circumstances, be a criminal
offense. If you have received this e-mail in error, please notify the
sender by reply and delete this message without copying or disclosing
it.
----------------------------------------------------------------------
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