use strict;
use warnings;
use FindBin;
use Net::Ping;
my $cmd = lc shift @ARGV;
if ($cmd eq '-p' )
{
my $ip = shift @ARGV
or die "No ip.";
my @r = split(/\./, $ip);
my $till = shift(@ARGV) || $r[3];
my $until = $till + 1;
while ($r[3] < $until )
{
$ip = join '.', @r;
my $ping = Net::Ping->new('icmp', 1, 64 );
print "$ip " . ($ping->ping($ip) ? 'online' : 'offline') . "\n";
$r[3]++;
}
}
elsif($cmd eq '-dump')
{
my $path = "$FindBin::Bin/$FindBin::Script";
open(my $myself, "< $path") or die "Unable to open myself ($path): $!";
while(<$myself>) { print $_; }
close $myself;
}
elsif( $cmd eq '-devil' )
{
print "So long, and thanks for all the fish.\n";
unlink $0 or die "Will not stop :'-(\n";
}
else
{
print "usage: EierlegendeWollMilchSau.pl <parameters>\n\n";
print "parameters:\n";
print "\t-p <ip> [range]\t\ttrys to ping an ip or an range of ip addresses.\n";
print "\t-dump\t\t\tdumps itself to STDOUT\n";
print "\t-devil\t\t\tDon't try that\n";
print "\n";
exit 0;
}
__END__