v-dev-redis01:/root# cat a1.pl
sub check_dns{
use LWP::UserAgent;
use Net::Ping;
$web = shift;
$p = Net::Ping->new("icmp");
if ($p->ping($web,2)){
return 1;
}
else {
return 0;
}} ;
$var=&check_dns("$ARGV[0]");
print "$var
";
v-dev-redis01:/root# perl a1.pl www.zjtest.com
1
If a default timeout ($def_timeout) in seconds is provided, it is used when a timeout is not given to the ping() method (below). The timeout must be greater than 0 and the default, if
not specified, is 5 seconds.