Baby Dunkin..
Dunking the baby in the pool!
Bash validate IP Address
Here is some code i found to validate ip addresses in bash.
Works good too..
#!/bin/bash
IPADDR="192.168.0.1"
function valid_ip(){
ERROR=0
oldIFS=$IFS
IFS=.
set -f
set -- $1
if [ $# -eq 4 ]
then
for seg
do
case $seg in
""|*[!0-9]*) ERROR=1;break ;;
## Segment empty or non-numeric char
*) [ $seg -gt 255 ] && ERROR=2 ;;
esac
done
else
ERROR=3 ## Not 4 segments
fi
IFS=$oldIFS
set +f
return $ERROR
}
if valid_ip $IPADDR ; then
echo "IP addr is OK"
else
echo "IP addr is invalid"
fi
The first post of my new site
This is my first post of my new site.
I hope there wil be more as ive spent a couple of hours working on this new site!
<welcome>Welcom to my new site</welcome>