curtisb has asked for the wisdom of the Perl Monks concerning the following question:

Ok, I'm confused. This is the first time I've used Net::Ping, so let me know if I'm missing something. I tookd this simple code off of the CPAN web site, to get a feel for Net::Ping before I start to write a script with it.
use Net::Ping; use strict; my $host="10.6.1.107"; my $p=Net::Ping->new(); print "$host is alive\n" if $p->ping($host); $p->close(); $p=Net::Ping->new("tcp");

When I run it on my windows NT machine with Active Perl and on my Linux box with Active perl, both do not print out if the machine is alive. I understand what the script is doing, I just cannot see where the problem is, if there is one. Did I do something wrong in the syntax?
Just trying to figure out!

curtisb

Replies are listed 'Best First'.
(Ovid) Re: Net::Ping and printing?
by Ovid (Cardinal) on Jan 12, 2002 at 02:42 UTC

    I had the same problem. Seems that, on an NT box, you need to run the script as "Administrator" and use icmp ping. I don't know enough about Linux to know why it wouldn't work there. See Net::Ping troubles for more information.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

(tye)Re: Net::Ping and printing?
by tye (Sage) on Jan 12, 2002 at 02:43 UTC

    See Net::Ping, the mini series for lots of information on this.

    If you are a local administrator under WinNT and/or are "root" under Linux, then you can probably switch to Net::Ping->new("icmp") to fix your immediate problem.

            - tye (but my friends call me "Tye")