You could do something else entirely, like:

larry$ a=a
larry$ echo $list
a|b|c
larry$ [[ $list =~ $a ]] && echo hi || echo ho
hi
larry$ a=d
larry$ [[ $list =~ $a ]] && echo hi || echo ho
ho

or

[[ "$(ls /clamscan/servers)" =~ $target_system ]] && parm_1="valid"

(assuming no system name is a subset of another system name. Otherwise:

[[ "$(ls /clamscan/servers)" =~ "
$target_system
" ]] && parm_1="valid"

to ensure $target_system matches exactly and all of one file name in
/clamscan/servers, but the $target_system token has to be in the first
column.

or, of course, you could go the direct route:

[[ -f /clamscan/servers/$target_system ]] && parm_1="valid"

James Melin wrote:
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



--
Carnegie Institution - At the Frontiers of Science



Larry Ploetz
Systems Administrator
Carnegie Institution of Washington
Department of Plant Biology, TAIR
650 325 1521 x 296 [EMAIL PROTECTED]

----------------------------------------------------------------------
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