Thread wer hat lust auf ein Spiel?
(61 answers)
Opened by conray at 2010-02-19 20:31 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 #!/usr/bin/perl use strict; use warnings; # History: # conray - 19.02.2010 : 19:31 UTC - initial version with ping (-p) # betterworld - 19.02.2010 : 19:44 UTC - minor changes # esskar - 19.02.2010 : 20:27 UTC - changes on ping, and dump myself command (-dump) use FindBin; use Net::Ping; #EierlegendeWollMilchSau.pl my $cmd = lc shift @ARGV; if ($cmd eq '-p' ) #ping { 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(MORE) { } 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 "\n"; exit 0; } __END__ |