Revision: 7843
Updated Code
at August 16, 2008 21:43 by rwczippy
Updated Code
#!/bin/sh
# Usage: domain2ip domain.name1 ... domain.nameN
if test $# -eq 0
then
echo "------------------"
echo "please add domain name to look up ex) domain2ip google.com foo.bar ..."
echo "------------------"
exit 1
fi
echo "------------------"
for names in $@
do
command=`nslookup $1 > d2ip.temp`
command=`grep NXDOMAIN d2ip.temp`
if test $? -eq 0
then
echo "$1 is not a valid IP address"
echo "------------------"
command=`rm -f d2ip.temp`
shift
elif test $? -eq 1
then
ipname=`cat d2ip.temp | grep -i name`
ipadd=`cut -f5 d2ip.temp | grep -i address`
echo "$ipname"
echo "$ipadd"
echo "------------------"
command=`rm -f d2ip.temp`
shift
else
echo "script exited for another reason! :-("
fi
done
exit 0
Revision: 7842
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 16, 2008 21:43 by rwczippy
Initial Code
#!/bin/sh
# File Name: domain2ip
# Author: robb corbett
# Date Written: 16 aug 2008
# Last Modified:
# Purpose: takes the domain name and returns the IP address via the nslookup command
# Usage: domain2ip domain.name1 ... domain.nameN
if test $# -eq 0
then
echo "------------------"
echo "please add domain name to look up ex) domain2ip google.com foo.bar ..."
echo "------------------"
exit 1
fi
echo "------------------"
for names in $@
do
command=`nslookup $1 > d2ip.temp`
command=`grep NXDOMAIN d2ip.temp`
if test $? -eq 0
then
echo "$1 is not a valid IP address"
echo "------------------"
command=`rm -f d2ip.temp`
shift
elif test $? -eq 1
then
ipname=`cat d2ip.temp | grep -i name`
ipadd=`cut -f5 d2ip.temp | grep -i address`
echo "$ipname"
echo "$ipadd"
echo "------------------"
command=`rm -f d2ip.temp`
shift
else
echo "script exited for another reason! :-("
fi
done
exit 0
Initial URL
Initial Description
uses nslookup to find the IP of the domain
Initial Title
domain name to IP address
Initial Tags
Bash, ip
Initial Language
Bash