From: Luis Giner on
I'm trying to get this case statement to check to make sure the user's
input starts with wks, if not give them an error. Question is, why
doesn't the ["!^wks"]* test bounce input that starts with the letters;
w, k or s? Any help would be appreciated.

L

read WKS?"Type the workstation name to modify or press x to exit. "

case $WKS in

"") echo "Entry cannot be blank.";echo "Try
again.";echo;checkw;;
wks) echo;echo "Invalid Entry, workstation must have a
numeric variable after wks.";echo;checkw;;
wks[A-Z,a-z]*) echo;echo "Invalid Entry, workstation must
have a numeric variable after wks.";echo;checkw;;
x) echo;echo "Exiting...Goodbye.";echo;exit;;
[!"^wks"]*) echo; echo "Invalid Entry, workstation must start
with wks."
# [!^w]*) echo; echo "Invalid Entry, workstation must start
with wks."
echo "Try again.";echo
checkw;;
wks[0-9]|wks[0-9][0-9]|wks[0-9][0-9][0-9]) echo;echo
"Workstation must have at least 4 numeric variables after wks.";
echo;checkw;;
wks[0-9][0-9][0-9][0-9]|wks[0-9][0-9][0-9][0-9][0-9]|wks[0-9]
[0-9][0-9][0-9][0-9][0-9])
cat $DIR$FILE|grep -w ^$WKS >/dev/null 2>&1
if [ $? != 0 ];then
echo; echo "ERROR! $WKS does not exist. Enter
a valid workstation name:"
echo
echo "This utility is for modifying existing
workstation line assignments only."
echo
sleep 3
checkw
else
WKSCHK
fi
;;


esac
From: Bill Marcum on
On 2010-05-21, Luis Giner <luis.e.giner(a)gmail.com> wrote:
> I'm trying to get this case statement to check to make sure the user's
> input starts with wks, if not give them an error. Question is, why
> doesn't the ["!^wks"]* test bounce input that starts with the letters;
> w, k or s? Any help would be appreciated.
Inside square brackets, '^' doesn't mean the beginning of the string.
Case statements use globbing syntax, not regular expressions, so you
don't need any special character to indicate the beginning. You could just
write patterns to match valid input and then "*)" for anything else.


From: Luis on
On May 21, 4:22 pm, Bill Marcum <b...(a)lat.localnet> wrote:
> On 2010-05-21, Luis Giner <luis.e.gi...(a)gmail.com> wrote:> I'm trying to get this case statement to check to make sure the user's
> > input starts with wks, if not give them an error.  Question is, why
> > doesn't the ["!^wks"]* test bounce input that starts with the letters;
> > w, k or s?  Any help would be appreciated.
>
> Inside square brackets, '^' doesn't mean the beginning of the string.
> Case statements use globbing syntax, not regular expressions, so you
> don't need any special character to indicate the beginning. You could just
> write patterns to match valid input and then "*)" for anything else.

I ended up adding this if statement prior to my case statement.

TEST=`echo $WKS|cut -c1-3`
if [ $TEST != wks ];then
echo; echo "Error! Workstation name must begin with a wks. Try
again.";
echo
sleep 2
checkw
fi

Thanks for your help.