[lug] Perl 101

John Karns jkarns at csd.net
Mon Apr 22 15:59:40 MDT 2002


On Mon, 22 Apr 2002, rm at fabula.de said:

> On Fri, Apr 19, 2002 at 01:44:10PM -0600, rise wrote:
> >
> > I'd be more inclined to guess firewalling that dislikes some
> > particular of Net::Ping's ICMP packets - he does note that he sees
> > activity lights for the pings and that code works for me with every
> > pingable IP I've tried (including setting up 192.168.1.108 on one of
> > my local interfaces).  The best way is probably to slap something
> > user-friendly like ipgrab on the interface and compare a command-line
> > ping with one from Net::Ping.  This kind of stuff is why Paul Barry's
> > perl networking book starts by building a packet sniffer for debugging
> > (well, that and it's fun).
>
>

> Hmmmmm. Tried the posted code (BTW, publishing a perl book that
> doesn't introduce test of a return code? Talk about teaching good
> coding habits early ...). The following is my modified version:

My thoughts were similar.  It really doesn't help to instill confidence in
the overall quality of the material - I had come to regard the products of
the publisher as being somewhat above what this set of books provides.


> Ok, i traced this and on the network i see the echo request as well as
> the echo reply from the remote host. I'd say something is fishy in the
> perl module (note: pingecho _is_ deprecated).

Interesting - glad to have some corroboration.  I also tried other
variations of the call, specifically:

use Net::Ping;
$p = Net::Ping->new("tcp");
print "$host is alive.\n" if $p->ping($host);
$p->close();

which also fails, both when run as root and a non-root user - am I correct
in assuming that this form supercedes the pingecho() call?  The call does
succeed when made as

$p = Net::Ping->new("icmp");

----------------------------------------------------------------
John Karns                                        jkarns at csd.net




More information about the LUG mailing list