Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- # Forum-Invaders
- # Write by: acpguedes
- use common::sense; #pode substituir por 'use strict;' + 'use warnings;'
- use Net::Ping;
- open IN, $ARGV[0] or die "Erro:$!\n\nUse: $0 <nome_do_arquivo_com_os_hosts>\n";
- my @hosts = <IN>;
- my $p=Net::Ping->new("icmp", 2);
- my @hostok;
- my @hostfail;
- for(my $i = 0; $i <= @hosts; $i++) {
- if($p->ping($hosts[$i])) {
- print "$hosts[$i] was successful: ",scalar(localtime)," \n";
- push (@hostok, $hosts[$i]);
- }
- else{
- print "$hosts[$i] falhou: ",scalar(localtime)," \n";
- push (@hostfail, $hosts[$i]);
- }
- }
- print "\n\nRelatorio:\n\nEndereços OK: @hostok", "\n\n", "Endereços Fail: @hostfail\n";
Add Comment
Please, Sign In to add comment