Perl script for batch whois

Posted: February 14, 2013 in Perl, snippets

I created a perl script that reads a file with domains to check and output the valid ones.It can also go through domain name combinations.


sub whois
#print “doing whois for “.$_[0].”: “;
my $domain = $_[0];
$domain =~ s/www\.//g;
open(WHOIS_CMD, “whois -h \”$domain\”|”) or die “Can’t run ‘$whois_cmd $domain’\n$!\n”;
{ # each line of output is put into $_
if ($_ =~ /No data was found to match the request criteria|No match|A C C E S S D E N I E D/i)
#print $_;
return 0;
return 1;
if ($#ARGV>(-1))
print $ARGV[0];

my $file = $ARGV[0];
open my $domains, $file or die “Could not open $file: $!”;

while( my $domain = <$domains>)
if (whois($domain)==1)
print “$domain : ok\n”;
print “$domain : fail\n”;

close $domains;

print “\n\n”;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s