[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: checking integers in scripts?



-----BEGIN PGP SIGNED MESSAGE-----

On Sun, Sep 19, 1999 at 10:24:17PM +0100, Steve George wrote:
> Hi,
> 
> I am trying to write a script to check if ipforwarding is running on my access box but I can't work out how to check for an integer in a script.  It may be clearer what I am trying to do for the bit of the script:
> 
> #Check if ipfwadm is on
> IPFORW = `cat /proc/sys/net/ipv4/ip_forward`
> if [ IPFORW == 0 ]; then
> 	echo "ipforwarding is OFF"
> 	exit 0
> fi



a few approaches:



IPFORW=`cat /proc/sys/net/ipv4/ip_forward`
#    ^^^ no spaces I assume



* if [ $IPFORW == 0 ] ; then echo "off"; fi
  #   ^^^ the $ sign

* if (test $IPFORW = 0); then echo "off"; fi


  # You might also come along without a variable:
* if [ `cat /proc/sys/net/ipv4/ip_forward` == 0 ] ; then echo "off"; fi



or totally different:

* if (/bin/grep 0 /proc/sys/net/ipv4/ip_forward -q) ; then echo "off"; fi


- -- 
Weasel                         http://www.cosy.sbg.ac.at/~ppalfrad/
PGP encrypted messages prefered.  See my site or finger -l ppalfrad
- -------------------------------------------------------------------
     A friend is someone who knows the song in your heart and
    can sing it back to you when you have forgotten the words.

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: noconv

iQCVAwUBN+Va57/AUNfRo6MpAQGvuwP9EL6rArYwiznOQryhEZj2agERiQ7kSXfo
876pmRd6HqoSjZxqdJ3SChgjSc04V13PKByMyuQewWjd86ns/efSnmJQKb1Uob0H
GUDw8VrDTlFmXHrg54FVr6dJ7MzqppX4x9YkKQEHpDFOBXiBCWhUenXGGEJQlfmR
oW9RMi9NYLk=
=ClRm
-----END PGP SIGNATURE-----


Reply to: