Reputation: 1
Stackoverflow community,
I am bran new to PERL scripting and need help [part of this script was from an internet source] to do an nslookup on a list of IP addresses in a file and loop through each one until I get to the end. If the domain name does not exist then do X, if it does do Y.
information for the below :
-existent - is a key word when nslookup aborts
name - is a key word when it works
listofhosts - is my ip address list
Thank you any help is greatly appreciated
#!/usr/bin/perl
#!c:\perl64\bin
use strict;
use warnings;
my $noname=-existent;
my $name=name;
open IPADDRESSES,("c:\\perl64\\scripts\\listofhosts.txt") or die("File could not be opened :$!");
my @list=<IPADDRESSES>;
foreach my $list(@list);
my $results=`nslookup $list`;
CHOMP ($list);
if ($noname) {
print ("no name")}
elsif ($name){
print ("IP address $list:\n");
print ("=\n");
print ("DNS name:$results\n");
}
close (IPADDRESSES);
Upvotes: 0
Views: 2914
Reputation: 31
Also try looking at Net::Nslookup instead of using nslookup ...
Upvotes: 1