[ale] A bash question

William A. Mahaffey III wam at hiwaay.net
Wed Sep 16 18:53:41 EDT 2009


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.



More information about the Ale mailing list