[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] A bash question
- Subject: [ale] A bash question
- From: wam at hiwaay.net (William A. Mahaffey III)
- Date: Wed, 16 Sep 2009 17:53:41 -0500
- In-reply-to: <[email protected]>
- References: <[email protected]>
On 09/16/09 17:06, Chuck Payne wrote:
> Guys,
>
> Sorry I am still a bit of NOOD on programmer and scripting. I have
> several boxes but a couple aren't SUSE, so iptables in not in
> /usr/sbin/iptables, I like to set up a VAR called $IPT can I do this,
> it a bash script...
>
> IPT=" if [ -e /sbin/iptables ] ; then
> /usr/sbin/iptables
> "
> Or
>
> if [ -e /sbin/iptables ] ; then
> IPT="/sbin/iptables"
> else
> IPT="/usr/sbin/iptables"
> fi
>
>
> I am looking for best practise. Thanks.
>
If you want a 1-liner, IPT=`which iptables` would work for tcsh, & I
*think* there is something similar in bash (hmmmm .... just checked &
'which' is an executable, used to be csh-specific, back in the day
....). If you look through the startup scripts in /etc/init.d/, you
might get some ideas about how to proceed, they often do that sort of
thing in there .... Your 2nd bit of coding above should work well & be
quite portable if necessary.
--
William A. Mahaffey III
----------------------------------------------------------------------
"The M1 Garand is without doubt the finest implement of war
ever devised by man."
-- Gen. George S. Patton Jr.