<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.32.2">
</HEAD>
<BODY>
Perhaps I didn't make it clear enough. Yes, the first approach of hard coding case values works. <BR>
<BR>
All the other approaches of trying to put the values in a variable do not work. <BR>
<BR>
<BR>
On Mon, 2015-08-03 at 12:33 -0400, Jim Kinney wrote:
<BLOCKQUOTE TYPE=CITE>
This works:
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
#!/bin/bash
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
FRED='one'
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
case $FRED in
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
one|two|pie) echo "got ${FRED}"; ;;
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
*) echo "crud"; ;;
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
esac
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
On Mon, 2015-08-03 at 12:03 -0400, Neal Rhodes wrote:
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BLOCKQUOTE TYPE=CITE>
Exactly how does not assign a list of values separated by pipe to use that variable later on in a script and make a CASE statement happy? <BR>
The script below shows a variety of attempts. <BR>
<BR>
Ultimately, we're aiming to grab the list from a file, eg "LIST="`cat allow.list`"<BR>
<BR>
<BR>
<BLOCKQUOTE>
REMOTE_ADDR=one<BR>
<BR>
case $REMOTE_ADDR in<BR>
one|two|three) echo "I like $REMOTE_ADDR" ;; # Picks this one.<BR>
*) echo "I do NOT like $REMOTE_ADDR" ;;<BR>
esac<BR>
<BR>
LIST="one|two|three"<BR>
case $REMOTE_ADDR in<BR>
$LIST) echo "But now I like $REMOTE_ADDR" ;;<BR>
*) echo "But now I do NOT like $REMOTE_ADDR" ;; # Picks this one.<BR>
esac<BR>
<BR>
case $REMOTE_ADDR in<BR>
"$LIST") echo "And I like $REMOTE_ADDR" ;;<BR>
*) echo "And I do NOT like $REMOTE_ADDR" ;; # Picks this one.<BR>
esac<BR>
<BR>
LIST="one"<BR>
case $REMOTE_ADDR in<BR>
"$LIST") echo "Yet I like $REMOTE_ADDR" ;; # Picks this one.<BR>
*) echo "Yet I do NOT like $REMOTE_ADDR" ;;<BR>
esac<BR>
<BR>
LIST="one\|two\|three"<BR>
case $REMOTE_ADDR in<BR>
$LIST) echo "However now I like $REMOTE_ADDR" ;;<BR>
*) echo "However now I do NOT like $REMOTE_ADDR" ;; # Picks this one.<BR>
esac<BR>
</BLOCKQUOTE>
<BR>
<PRE>
_______________________________________________
Ale mailing list
<A HREF="mailto:Ale@ale.org">Ale@ale.org</A>
<A HREF="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</A>
See JOBS, ANNOUNCE and SCHOOLS lists at
<A HREF="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</A>
</PRE>
</BLOCKQUOTE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<PRE>
--
James P. Kinney III
Every time you stop a school, you will have to build a jail. What you
gain at one end you lose at the other. It's like feeding a dog on his
own tail. It won't fatten the dog.
- Speech 11/23/1900 Mark Twain
http://heretothereideas.blogspot.com/
</PRE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<PRE>
_______________________________________________
Ale mailing list
<A HREF="mailto:Ale@ale.org">Ale@ale.org</A>
<A HREF="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</A>
See JOBS, ANNOUNCE and SCHOOLS lists at
<A HREF="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</A>
</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>