Created
May 5, 2019 11:03
-
-
Save rankun203/7c72a105d5fa406a09472215e4606818 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use 5.010; | |
# ./ping-google.perl google.com | |
use Net::Ping; | |
my $host = "$ARGV[0]" || 'google.com'; | |
my $p = Net::Ping->new('icmp'); | |
my ($ret, $duration, $ip) = $p->ping($host); | |
say "Success(1): ${ret}"; | |
say "Duration(s): ${duration}"; | |
say "IP(of ${host}): ${ip}"; | |
if ($ret == 0) { | |
say "Failed to connect to host ${host}"; | |
$p->close(); | |
exit -1; | |
} else { | |
$p->close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment