bpeterse,
I think that you got it wrong. The dig command takes lots of time, so grep won´t help either
Main Topics
Browse All TopicsHi,
I have a huge list of domains(one per line, in a text file) and all I need to do is to check if this domain exists or not. If it exists, the domain should be printed on stdout, so I can pass it as parameter to another program.
I think that checking for the dns records with the unix command "dig" would work, but it takes too much time... maybe I have to pass some parameters, so it can ask for fewer information and, therefore, return the desired result quickly.
Here is a example of a domain that exist under my TLD: google.com.br and one that doesn´t: nonexistantdomain.com.br
It can´t be done using my TLD´s whois tool, since it´ll block me after a few requests.
A shell script or some python/ruby code would be great.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sorry, I´ll try to make it more clear.
You´re right, there is a local file, with one domain per line. I knew that I could use some unix command to pass each line as parameter to another command tool...
But the problem is that the "dig" commmand takes too much time to execute. So I need to know if there are some parameters that I could pass along dig to make it faster OR if there is another alternative to check if a domain exist or not.
Thanks!
well, I would rather use whois command to check if the domain name is registered.
http://www.linuxconfig.org
Hi Sligowaths,
There are Ruby and Python modules for whois interface: http://whois.rubyforge.org
The problem with large number of whois query is that they depends on the bandwidth and speed of the network. Just out of curiosity, how many domains are you trying to lookup?
Luxana,
Like I said before, my registrar'll block me after making lots of queries...
Sylong,
Thanks for your help, but I have managed to make my own simple solution.
here it is, in case of anybody else needs.
import os, sys
f = open("hugelist.txt")
lines = f.readlines()
for line in lines:
domain = line[0:-2] # remove \r\n from windows encoding
host = "host " + domain
h = os.popen(host)
str = h.readline()
if str.find("not found") > 0:
print >> sys.stdout,
Moderador: How can I proced to split up the points with everyone who tried to help me?
Business Accounts
Answer for Membership
by: bpetersePosted on 2007-05-21 at 08:51:41ID: 19127682
Why not use grep:
`grep <domain> <domain_list.txt>`