Re: validate IP address via bash - anyone have one!

This is a discussion on Re: validate IP address via bash - anyone have one! within the Linux Administration forums, part of the Linux Forums category; On 10 Aug 2003 20:27:37 -0700, hallian wrote: > Hello - > > Anybody using a script to validate ...


Go Back   Usenet Forums > Linux Forums > Linux Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-11-2003
Bit Twister
 
Posts: n/a
Default Re: validate IP address via bash - anyone have one!

On 10 Aug 2003 20:27:37 -0700, hallian wrote:
> Hello -
>
> Anybody using a script to validate IP address in bash! Just finding a
> quick fix rather than getting into those regular expression! It would
> be helpful, if someone could shoot me out a link!


http://www.tldp.org/LDP/abs/html/index.html

snippet from my ckip script to test multi ip address for a FQDN.

_isp=comcast.net
_domain=${_isp}

tput clear
echo

_fn=/tmp/mail
host mail.${_domain} > $_fn
chmod 666 $_fn

_mail_name="mail.${_domain}"
_item_count=0
_item_total=4

while read line
do
set -- $line

if [ $1 != $_mail_name ] ; then
echo "1: mail $1 <> $_mail_name modify /etc/postfix/main.cf sender_cano
nical"
fi

shift $(($#-1))

case $1 in
63.240.76.10) _item_count=$(($_item_count+1)) ;;
204.127.202.10) _item_count=$(($_item_count+1)) ;;
204.127.198.10) _item_count=$(($_item_count+1)) ;;
216.148.227.80) _item_count=$(($_item_count+1)) ;;
*) echo "2: Mail: invalid last word $1"
echo $line
echo Modify firewall
;;
esac
done < $_fn

if [ $_item_count != $_item_total ] ; then
echo 3: Item count $_item_count ne $_item_total
cat $_fn
fi

if [ $_deb -eq 0 ] ; then
/bin/rm $_fn
fi

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:47 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0