Subversion Repositories sysadmin_scripts

Rev

Blame | Last modification | View Log | Download | RSS feed

#! /usr/bin/perl -w

sub getWhois {
   my $domain = shift;
   my @results;
   my $filename = "cache/$domain.whois";
   if ( -e $filename ) {
      print STDERR "Looking up $domain from cache\n";
      open WHOIS,"<$filename" or die "Could not read $filename: $!";
      @results = <WHOIS>;
      close WHOIS;
   } else {
      @results = `whois $domain`;
      print STDERR "Retrieving $domain from whois\n";
      sleep(15);
      open WHOIS,">$filename" or die "Could not write to $filename: $!";
      print WHOIS @results;
      close WHOIS;
   }
   return @results;
}

sub checkDomain {
   my $domain = shift;
   my @results = getWhois( $domain );
   my $good = 0;
   while ( ! $good and ($line = shift @results)) {
      $good = 1 if ($line =~ m/ns.dailydata/i)
   }
   print "$domain\t" . ($good ? 'ok' : 'BAD') . "\n";
}

#open DOMAINS, '<domainlist' or die "Could not open domainlist: $!";
my $i = 0;
while ( my $domain = <> ) {
   chomp $domain;
   next unless $domain;
   &checkDomain( $domain );
}
#close DOMAINS;
1;