Kozz has asked for the wisdom of the Perl Monks concerning the following question:
Then within the if/else construct I would place an exec() call (to fetchmail with the desired parameters once I knew the ping portion was working correctly.#!/usr/bin/perl -w use strict; use Net::Ping; my $fetchmail = '/usr/local/bin/fetchmail'; my @fetchmail_args = ('-s', '-t', '60'); my $hostname = 'hostname'; # an external host my $timeout = 3; my $p = Net::Ping->new('udp', $timeout); if( $p->ping($hostname) ){ print "$hostname is alive.\n"; # exec($fetchmail, @fetchmail_args); }else{ print "$hostname is unreachable.\n"; }
However, when putting the external hostname in $hostname, it always returns "unreachable", yet I can still use /bin/ping to reach it just fine. So I tried for a $hostname also 'localhost', '127.0.0.1', and also the local interface's IP address, '10.0.0.1'. But they also all return unreachable.
What am I doing wrong? It must be something quite simple... Thank you for your consideration.
--Kozz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Module Net-Ping
by Preceptor (Deacon) on Sep 23, 2002 at 16:54 UTC | |
by Kozz (Friar) on Sep 23, 2002 at 17:04 UTC | |
by blm (Hermit) on Sep 23, 2002 at 17:34 UTC | |
by Preceptor (Deacon) on Sep 23, 2002 at 17:49 UTC | |
by sauoq (Abbot) on Sep 23, 2002 at 21:35 UTC | |
by Kozz (Friar) on Sep 24, 2002 at 14:21 UTC | |
by Kanji (Parson) on Sep 23, 2002 at 17:48 UTC | |
by Preceptor (Deacon) on Sep 23, 2002 at 17:13 UTC | |
|
Re: Module Net-Ping
by Enlil (Parson) on Sep 23, 2002 at 17:06 UTC |