Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/usr/bin/perl
- use strict;
- use warnings;
- use Net::Ping::External qw(ping);
- use IO::Socket;
- my $ip_address;
- my $ip_network;
- my $packed_ip;
- print "Please enter the ip or the FQDN that you want to ping: \n";
- chomp (my $scanme=<>);
- use Socket;
- if ($scanme =~ /\d/){
- $packed_ip = gethostbyaddr("$scanme",AF_INET);
- $ip_network = inet_aton($scanme);
- $ip_address = inet_ntoa($ip_network);
- my $alive = ping(host => "$scanme");
- print "$packed_ip \n";
- print "$scanme is resolved to $packed_ip \n";
- print "ping: $scanme is reachable \n" if $alive;
- }
- elsif ($scanme !~ m/\d/) {
- $packed_ip = gethostbyname("$scanme");
- print "hejsan";
- }
- else{
- print "Input error try again";
- }
Advertisement
Add Comment
Please, Sign In to add comment