SPUG: I must be missing something with Net::Ping

Chris Wilkes cwilkes at ladro.com
Mon Oct 8 19:58:05 CDT 2001


On Mon, 8 Oct 2001, Alyssa Harding wrote:

> my $p = Net::Ping->new();  # by default uses icmp protocol

My docs for Net::Ping says that it uses the UDP protocol by default.  The
main reason for this is that you have to be root to open an ICMP socket,
and since you probably aren't root when running a script it should
default to what can normally be used. Ping is normally setuid root so that
an average user can use it.

If you say
	my $p = Net::Ping->new('icmp');
you'll be able to run your program, but you have to be root.  It would be
nice if there were a way around this but I can't think of any off the top
of my head.  You could do something easy like `ping $ip` and grep through
the results.

Chris


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/





More information about the spug-list mailing list