him

Untitled

him
May 2nd, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #/bin/bash/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use Net::Ping::External qw(ping);
  6. use IO::Socket;
  7. my $ip_address;
  8. my $packed_ip;
  9. print "Please enter the ip or the FQDN that you want to ping: \n";
  10.  
  11. chomp (my $scanme=<>);
  12.  
  13. use Socket;
  14. $packed_ip = gethostbyname("$scanme");
  15. if (defined $packed_ip) {
  16. $ip_address = inet_ntoa($packed_ip);
  17. }
  18. my $host = $ip_address;
  19. my $i;
  20. $host = IO::Socket::INET->new(PeerAddr=>$ARGV[0],PeerPort=> $i,proto=>'tcp',Timeout=>1) and print "Port $i is open\n";
  21.  
  22. my $alive = ping(host => "$scanme");
  23. print "$scanme is resolved to $ip_address \n";
  24. print "ping: $scanme is reachable \n" if $alive;
Advertisement
Add Comment
Please, Sign In to add comment