[Eric: sorry if you see this twice. Resending online. hit REPLY instead of REPLY ALL by accident]


On Jan 3, 2005, at 3:49 PM, Eric F Crist wrote:

First off, let me thank you very much for the massive amount of
information you've given me thus far.

I am a commandline geek from way back, so you're welcome.

My brother actually had a Dilbert from years ago that he gave me where Dilbert runs into a guy with a long beard and suspenders and says "Hey, you're one of those Unix geeks, aren't you?"

I wish I could get that on a T-Shirt!

Anyway, the sourcing idea is definitely a good one. I'm not usually working with such easy source material (I do a lot of stuff where I'm pulling information off a website, etc)

  Do me a favor and tell me if
this syntax is correct:

#!/bin/sh

. /etc/rc.conf

if [ "$grog_firewall_enable" = "YES" ]
then
         echo "Firewall enabled."
elif [ "$grog_firewall_enable" = "NO" ]
then
         echo "Firewall disabled."
fi

exit 0

yes, that's right

This seems to work when I try it at a command line.  There's one other
question. How would I add the following line (please correct syntax):

elif [ "$grog_firewall_enable" <> "YES" or "NO" ]
then
                echo "Syntax error in /etc/rc.conf file. grog_firewall_enable 
must be
YES or NO"
fi

Ah, ok. When you are done with the "elif" (short for "else if" BTW) you may use an "ELSE" that covers everything else.


Since you've already matched for YES and NO then all you need is to add in a catch-all (NOTE: there is no "THEN" when dealing with ELSE. only IF or ELIF takes a THEN

if [ "$grog_firewall_enable" = "YES" ]
then
         echo "Firewall enabled."

elif [ "$grog_firewall_enable" = "NO" ]
then
         echo "Firewall disabled."

else
echo "Syntax error in /etc/rc.conf file. grog_firewall_enable must be YES or NO"

exit 1
fi


the 'exit 1' is optional. If you include it, the script will end right there, which may or may not be ideal.

TjL

_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to