Guest User

Untitled

a guest
Aug 12th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.67 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. # Forum-Invaders
  4. # Write by: acpguedes
  5.  
  6. use common::sense; #pode substituir por 'use strict;' + 'use warnings;'
  7. use Net::Ping;
  8.  
  9. open IN, $ARGV[0] or die "Erro:$!\n\nUse: $0 <nome_do_arquivo_com_os_hosts>\n";
  10. my @hosts = <IN>;
  11.  
  12. my $p=Net::Ping->new("icmp", 2);
  13.  
  14. my @hostok;
  15. my @hostfail;
  16.  
  17. for(my $i = 0; $i <= @hosts; $i++) {
  18.     if($p->ping($hosts[$i])) {
  19.         print "$hosts[$i] was successful: ",scalar(localtime)," \n";
  20.         push (@hostok, $hosts[$i]);
  21.     }
  22.     else{
  23.         print "$hosts[$i] falhou: ",scalar(localtime)," \n";
  24.         push (@hostfail, $hosts[$i]);
  25.     }
  26. }
  27.  
  28. print "\n\nRelatorio:\n\nEndereços OK: @hostok", "\n\n", "Endereços Fail: @hostfail\n";
Add Comment
Please, Sign In to add comment