Created
November 22, 2011 05:24
-
-
Save ryochin/1384967 to your computer and use it in GitHub Desktop.
Net::Ping in 'syn' mode
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/perl -- | |
use strict; | |
use Net::Ping; | |
my $p = Net::Ping->new("syn"); | |
$p->port_number( scalar getservbyname("http", "tcp") ); | |
$p->hires(1); | |
my $host = shift @ARGV // "127.0.0.1"; | |
my $timeout = 2; # sec | |
if( $p->ping( $host, $timeout ) and $p->ack( $host ) ){ | |
warn "ok"; | |
} | |
else{ | |
warn "not ok"; | |
} | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment