meh, I typically just use a simple bash for loop for that..this requires bash 3.x. either save it for export it as a function within your shell. You call it like: "foo.sh 149.101.1 nmap -O > my-output"
for ip in {1..254}; do
${@:2} ${1}.ip
done
it should also be noted that nmap supports doing a range of IPs natively. Also, nmaping a range of IPs for no reason is really lame. Whois servers also have a tendency to block you IP.
Also, I don't know where you learned perl, but your code looks terrible. Just to go down it line by line:
#!/usr/bin/perl
You should use /usr/bin/perl -w to print warnings and such. Also you should write your programs with 'use strict;'
($arg) = @ARGV;
Uhg, just use $ARGV[0]. or if you're going to call the first argument something, call it something meaningful. "$arg" isn't any better than $ARGV[0] in terms of readablity. Also, it would be better written as "my $tries = shift @ARGV"
if ($arg eq "-h") { print "USAGE ./net-seek.pl <n> where <n> = 1,2,3,...,inf\n
makes an output, net-seek.OUT.txt"; exit;}
if ($arg eq "") { print "type ./net-seek.pl -h for help.\n"; exit; }
if ($arg eq "-s") { print "[b][color=red]My own mediocre attempt at humor has been highly amusing to myself.[/color][/b] HI\n"; exit;}
All of these lines suck for the same reason. You never test to see if the input is what you expect it to be, namely a digit. Cut the crap too, its not cool. The whole thing would be better written as:
if ($tries !~ /^\d+$/) {
print "Usage: $0 <n>\n";
exit 1;
}
print "what network tool would you like to sex?... ";
$tool = <STDIN>; chomp $tool; $n = 0;
What the hell is that crap? Why don't you just read the command to run on the command line like any other normal human?
while ($n < $arg) { $range = 255;
$ran0 = int(rand($range)); $ran1 = int(rand($range));
$ran2 = int(rand($range)); $ran3 = int(rand($range));
system ("$tool $ran0.$ran1.$ran2.$ran3 >> net-seek-OUT.txt"); $n++;}
so wait, couldn't that generate 0.0.0.0? Is that a valid IP? and couldn't it generate 255.255.255.255? Wouldn't that also generate IPs in the D and E class, which are multicast and unused? Who the hell taught you to format code like that? Also, why the hell should I have to save my output as "net-seek-OUT.txt"? Why don't you check to make sure that I can actually write to "net-seek-OUT.txt". Why aren't you using a for loop if you're going to increment the counter the same way every time? Why do you set $range every single time you're in that loop?