/ Published in: Bash
                    
                                        
uses nslookup to find the IP of the domain
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
#!/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
Comments
 Subscribe to comments
                    Subscribe to comments
                
                