jjamd64
February 29, 2008, 3:17pm
1
I have a script that does domain name lookups, and I also have a file with one domain name per line. I would like to have a script that calls the domain name lookup script for each domain that is in the file. Any help is very much appreciated.
The text file would be something like this
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!
Lycos, Inc., is a web search engine and web portal established in 1994, spun out of Carnegie Mellon University. Lycos also encompasses a network of email, webhosting, social networking, and entertainment websites.
This is the domain name lookup script:
#!/bin/sh
whois $1 | grep "Registrar:" |sed 's/ //'|awk '{print $1"===|"$2 , $3 , $4 , $5 , $6 , $7}'
whois $1 | grep "Name Server"|sed 's/ //'|awk '{print $1 $2"==|"$3}'
dig +short $1 mx |awk '{print "MX:==========|"$1 , $2}'
dig mail."$1"|grep mail."$1"|grep CNAME |awk '{print "CNAME:=======|" $1}'
dig +short mail."$1"|while read ms;do
case $ms in
([0-9]) printf "%s\n" "IP:==========|$ms";;
( ) printf "%s\n" "Points to:===|$ms"
esac;
done
Again, any help is very much appreciated.
-JJ
matt.d
February 29, 2008, 3:57pm
2
Let's say the file with a domain name on each line is called "domains.txt" and your script is called "lookup.sh" --
#!/bin/sh
for entry in `cat domains.txt`
do
lookup.sh $entry
done
Let me know if that works.
Edit: Forgot to add that you should put the full path to both the file and the shell script for best results.
jjamd64
February 29, 2008, 4:15pm
3
Yup, that works. I actually figured it out myself, but I did it slightly differently so I wouldn't need a separate script for the lookup:
#!/bin/sh
#--------------------------
process_domain ()
{
whois $1 | grep "Registrar:" |sed 's/ //'|awk '{print $1"===|"$2 , $3 , $4 , $5 , $6 , $7}'
whois $1 | grep "Name Server"|sed 's/ //'|awk '{print $1 $2"==|"$3}'
dig +short $1 mx |awk '{print "MX:==========|"$1 , $2}'
dig mail."$1"|grep mail."$1"|grep CNAME |awk '{print "CNAME:=======|" $1}'
dig +short mail."$1"|while read ms;do
case $ms in
([0-9]) printf "%s\n" "IP:==========|$ms";;
( ) printf "%s\n" "Points to:===|$ms"
esac;
done
}
#---------------------------
for line in `cat domains.txt`
do
process_domain $line
done
Feel kinda silly asking for help on this one...just needed "for" and backticks...but thanks for your help Matt, I really appreciate it.
JJ