|
|
 |

|

 |

| Community » Perl: Allgemeines Forum |
|
Net::Ping Problem
|
Seitenanfang |
| Hallo, ich hab ein kleines Problem mit oben genanntem Modul. Das funktioniert nicht so wie es laut Doku sollte. Mein Code sieht wie folgt aus:
use Net::Ping;$host=irgendein host; my $p = Net::Ping->new('tcp'); unless (defined $p) { die "can't create Net::Ping object $!";} if ($p->ping($host)) { print "$host is reachable via tcp\n" ; } else { print "$host is unreachable via tcp\n"; } $p->close;
Der Host, der beim codebeispiel nicht dabei ist, ist definitiv per ping erreichbar. Das Skript liefert mir aber immer ein unerreichbar zurück. Was mach ich falsch? Beste grüße Calavero
Datum: 26.07.2005-16:02

|
re: Net::Ping Problem
|
Seitenanfang |
| Hi, bitte dringend RFC 792 Internet Control Message Protocol anschauen. Gepingt wird mit icmp.
my $p = Net::Ping->new('icmp');
-uw
Datum: 26.07.2005-17:43

|
re: Net::Ping Problem
|
Seitenanfang |
| Hallo, danke für die Antwort. ICMP funktioniert aber nur wenn das Skript als root läuft. Das tut es aber nicht. Es muss doch möglich sein auch als nicht-Root ein ping abzusetzen. Beste Grüße Calavero
Datum: 26.07.2005-18:06

|
re: Net::Ping Problem
|
Seitenanfang |
| Hmmm, sorry, my fault. :-\ [me@host:~/work]$ perldoc Net::Ping Net::Ping(3) User Contributed Perl Documentation Net::Ping(3) [...] $p = Net::Ping->new("tcp", 2); # Try connecting to the www port instead of the echo port $p->{port_num} = getservbyname("http", "tcp"); while ($stop_time > time()) { print "$host not reachable ", scalar(localtime()), "\n" unless $p->ping($host); sleep(300); } undef($p); [...]
Schätze, dass Du explizit Protokoll, Service und Port angeben musst.-uw
Datum: 26.07.2005-18:56

|
re: Net::Ping Problem
|
Seitenanfang |
| Hallo TbHoCne, danke...das war die Lösung. Beste Grüße Calavero
Datum: 27.07.2005-10:41

|
|

|

|

|
 |

|

|
|