Jan 26, 2015, 7:41 AM
Post #1 of 1
I'm a placement student and I've been given the task to write a perl script to scan a given IP block, ping each IP within the block, return true if the IP is reachable and output all data to a csv file.
I'm going to be building on this script over the next few weeks to eventually compile all network information into a csv file (thinking of it like a network database). I've started a bit but I'm no guru and I'm only self taught so I'm having trouble figuring out where to go from here and how to get there.
I want to be able to run the script and give it a IP range or CIDR block and the script to ping every IP in the range or block and output to a csv file the IP that was pinged and if it was reached.
perl map.pl 130.15.241/24
Here is the code I have so far.
my $block = new Net::Netmask ($ARGV);
print "Max Block:\t".$block->maxblock()."\n";
open (CSVFILE, ">", "csvfile.out") || die "Cannot open file 'csvfile.out' $!";
close (CSVFILE) || die;
I know I can give it a range or CIDR block and it will return the basic information. I'm guessing I'll need the Net::Ping or something similar to do the pinging but I don't understand how.
Any help would be greatly appreciated.