Hi,
I am back with some updated script on the Whois script. I did manage to create a script which reads each line from a text file and then dumps the nameserver of each domain in another file. It ran good for a file that has 3-4 domains but when i added all the domains(may be 40-50) it started crashing. I try to fix but i think i broke the whole thing.
Here is the code for the existing script that does not run. Any suggestions ?
#!/usr/bin/perl
use warnings;
use CGI::Carp qw/fatalsToBrowser/;
use Net::DNS;
my $res = Net::DNS::Resolver->new;
my $logTime = gmtime(time);
open(fileIN,"domains.txt") or dienice("Cannot open domains list: $!");
@logData = <fileIN>;
close(fileIN);
print header("text/plain");
print "Header :: $logTime \n";
foreach $line(@logData)
{
chomp($line);
my $dom = $line ;
my $query = $res->query($dom, "NS");
if ($query) {
open(fileOUT, ">>log.txt") or dienice("Can't open log.txt for writing:
+ $!");
flock(fileOUT, 2);
seek(fileOUT, 0, 2);
print fileOUT "$dom : ";
print "$dom : ";
foreach $rr (grep { $_->type eq 'NS' } $query->answer) {
print fileOUT $rr->nsdname, ",";
print $rr->nsdname, ",";
}
}
print "\n",<br>;
print ".",<br>;
print <<EndHTML;
Added domain : $dom <br>
EndHTML
}
close (fileOUT);
sub dienice
{
my($msg) = @_;
print "<html>\n<head>\n<title>Error Opening File!</title>\n";
print "</head>\n";
print "<body><h2>Error</h2>\n<b>";
print $msg;
print "\n</b></body>\n</html>";
exit;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.