From owner-freebsd-questions@FreeBSD.ORG Mon Jan 3 21:48:00 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D6D4416A4CE for ; Mon, 3 Jan 2005 21:48:00 +0000 (GMT) Received: from spatula.dreamhost.com (spatula.dreamhost.com [66.33.205.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id BA55643D39 for ; Mon, 3 Jan 2005 21:48:00 +0000 (GMT) (envelope-from lists@tntluoma.com) Received: from [192.168.2.102] (unknown [68.254.13.39]) by spatula.dreamhost.com (Postfix) with ESMTP id 2A55717D08F; Mon, 3 Jan 2005 13:47:58 -0800 (PST) In-Reply-To: <4BFD88E8-5DCE-11D9-B56F-000D9333E43C@secure-computing.net> References: <06DDB71C-5DB4-11D9-B56F-000D9333E43C@secure-computing.net> <15416223037.20050103193803@hexren.net> <6074EB8D-5DC6-11D9-89A5-000D93AD26C8@tntluoma.com> <0CE27994-5DCD-11D9-89A5-000D93AD26C8@tntluoma.com> <4BFD88E8-5DCE-11D9-B56F-000D9333E43C@secure-computing.net> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <22B51A59-5DD1-11D9-89A5-000D93AD26C8@tntluoma.com> Content-Transfer-Encoding: 7bit From: Timothy Luoma Date: Mon, 3 Jan 2005 16:47:59 -0500 To: Eric F Crist X-Mailer: Apple Mail (2.619) cc: FreeBSD-Questions Questions Subject: Re: my lame attempt at a shell script... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jan 2005 21:48:01 -0000 On Jan 3, 2005, at 4:27 PM, Eric F Crist wrote: > Good to know. If I want to validate, like my first example, against > some variables, how would I do that best. Say, for example, I have 4 > possible entries for grog_firewall_enable but I want to single out > three of them: > > if [ "$grog_firewall_enable" <> "YES" OR "NO" OR "OPEN" ] > > is this the correct syntax? Can't seem to figure this one out. Instead of <> you want to use != when working in (ba)sh. I no of no way to test A != (B or C or D) on one line like that in bash. I think the closest you can come is using 'case': case $grog_firewall_enable in YES|NO|OPEN) : ;; *) echo Illegal value for grog_firewall_enable ;; esac the ":" in that case is just a placeholder. You could replace it with some commands, even your previous IF/ELIF statements if you wanted to. TjL ps - in case it wasn't obvious, and it wasn't to me when I first started, "fi" is "if" spelled backwards and "esac" is "case" spelled backwards. Makes it easier to remember how to spell them correctly ;-)