这有点简单,不过却够你想半天。
以下是我的命令行拷贝,请各位帮我看看为什么不对。
G:\work\perl>type tt.pl
use Net::Ping;
$host="61.128.128.68";
$p = Net::Ping->new();
print "$host is alive.\n" if $p->ping($host);
$p->close();
G:\work\perl>ping 61.128.128.68
Pinging 61.128.128.68 with 32 bytes of data:
Reply from 61.128.128.68: bytes=32 time<10ms TTL=252
Reply from 61.128.128.68: bytes=32 time<10ms TTL=252
Reply from 61.128.128.68: bytes=32 time=10ms TTL=252
Reply from 61.128.128.68: bytes=32 time=11ms TTL=252
Ping statistics for 61.128.128.68:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 11ms, Average = 5ms
G:\work\perl>perl tt.pl
G:\work\perl>
为什么我使用tt.pl这个程序后没有报告我说这个站点活着。