him

Untitled

him
May 2nd, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use Net::Ping::External qw(ping);
  6. use IO::Socket;
  7.  
  8. my $ip_address;
  9. my $ip_network;
  10. my $packed_ip;
  11. print "Please enter the ip or the FQDN that you want to ping: \n";
  12.  
  13. chomp (my $scanme=<>);
  14.  
  15. use Socket;
  16. if ($scanme =~ /\d/){
  17. $packed_ip = gethostbyaddr("$scanme",AF_INET);
  18. $ip_network = inet_aton($scanme);
  19. $ip_address = inet_ntoa($ip_network);
  20.  
  21. my $alive = ping(host => "$scanme");
  22. print "$packed_ip \n";
  23. print "$scanme is resolved to $packed_ip \n";
  24. print "ping: $scanme is reachable \n" if $alive;
  25. }
  26. elsif ($scanme !~ m/\d/) {
  27. $packed_ip = gethostbyname("$scanme");
  28. print "hejsan";
  29. }
  30.  
  31. else{
  32. print "Input error try again";
  33. }
Advertisement
Add Comment
Please, Sign In to add comment