my lame attempt at a shell script...
lists at tntluoma.com
Mon Jan 3 13:22:47 PST 2005
[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:
> . /etc/rc.conf
> if [ "$grog_firewall_enable" = "YES" ]
> echo "Firewall enabled."
> elif [ "$grog_firewall_enable" = "NO" ]
> echo "Firewall disabled."
> 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" ]
> echo "Syntax error in /etc/rc.conf file. grog_firewall_enable must be
> YES or NO"
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" ]
echo "Firewall enabled."
elif [ "$grog_firewall_enable" = "NO" ]
echo "Firewall disabled."
echo "Syntax error in /etc/rc.conf file. grog_firewall_enable must be
YES or NO"
the 'exit 1' is optional. If you include it, the script will end right
there, which may or may not be ideal.
More information about the freebsd-questions