brolouille | bonjour
Bon je comprend rien a cette commande .
Lorsque j'effectue un ping pour la premiere fois sur une machine, le Net::Ping n'arrive pas a la trouver.
Alors que lorsque j'effectue un 'ping monadr', la machine repond.
Je réessaie alors avec le module Net::Ping et la il arrive a le trouver.
Qqn peut-il m'expliquer pliz?
voici mon code
Code :
- #!/usr/bin/perl -w
- use strict;
- use Net::Ping;
- use Socket;
- my $host = $ARGV[0] || die "Usage: $0 ipaddr";
- my $null = system ("ping $host -c 1" );
- my $p = Net::Ping->new("tcp",1);
- unless ($p->ping($host)) {
- print "\nfail: ",scalar(localtime),"\n";
- }else {
- print "\nsuccess: ",scalar(localtime),"\n";
- }
|
et quand j'execute pour la 1ere fois :
Code :
- @# ./arp_table.pl 192.168.0.12
- PING 192.168.0.12 (192.168.0.12) 56(84) bytes of data.
- From 192.168.0.12: icmp_seq=1
- 64 bytes from 163.9.4.98: icmp_seq=1 ttl=255 time=1.17 ms
- --- 192.168.0.12 ping statistics ---
- 1 packets transmitted, 1 received, 0% packet loss, time 0ms
- rtt min/avg/max/mdev = 1.172/1.172/1.172/0.000 ms
- fail: Wed May 26 19:12:41 2004
|
alors que la 2e fois ca marche:
Code :
- @# ./arp_table.pl 192.168.0.12
- PING 192.168.0.12 (192.168.0.12) 56(84) bytes of data.
- 64 bytes from 192.168.0.12 icmp_seq=1 ttl=255 time=0.304 ms
- --- 192.168.0.12 ping statistics ---
- 1 packets transmitted, 1 received, 0% packet loss, time 0ms
- rtt min/avg/max/mdev = 0.304/0.304/0.304/0.000 ms
- success: Wed May 26 19:20:03 2004
|
|