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

Oh Estimable Monks, please shine favor on a lowly accolyte,

I am trying to use Net::Ping in the simplest possible way and the utility doesn't "see" a local system on the LAN that I can manually ping. I am using the ActiveState 5.6 on Windows NT 4.0 SP 6a and I'm pinging a Redhat Linux 6.2 system.

Here is the code: use Net::Ping; $push_ip_address="192.168.0.27"; print "$push_ip_address\n"; #just for grins $p = Net::Ping->new(); print "OK \n" if $p->ping("$push_ip_address",2); print "Pval $p\n"; #just to see print "Nuts!! \n" unless $p->ping($push_ip_address,2); $p->close(); Here is the result: D:\test>perl testftp.pl 192.168.0.27 Pval Net::Ping=HASH(0x1b9f08c) Nuts!! done So it doesn't appear to see the system. Yet, wise ones... D:\test>ping 192.168.0.27 Pinging 192.168.0.27 with 32 bytes of data: Reply from 192.168.0.27: bytes=32 time<10ms TTL=255 Reply from 192.168.0.27: bytes=32 time=10ms TTL=255

My fingers can see the node... woe is me.

Would you please advise as to my shortcomings?

Many that they are.

Diskcrash

Replies are listed 'Best First'.
Re: Perfectly Poor Ping Problem
by goldclaw (Scribe) on Feb 23, 2001 at 04:16 UTC
    Have you tried setting the first argument of new to "icmp"? By default Net::Ping sends a udp packet on the echo port, while the ping command usually sends an icmp echo message.

    GoldClaw

      You are truly a wise and generous monk!

      It works without flaw or delay. I had tried the tcp proto and it caused a demand for alarms. This is great. Many Thanks!

      Diskcrash

Re: Perfectly Poor Ping Problem
by boo_radley (Parson) on Feb 23, 2001 at 04:16 UTC
    rather than using things like
    print "OK \n" if $p->ping("$push_ip_address",2);
    try
    $p->ping("$push_ip_address",2) || die "Can't ping address $push_ip_add +ress -- perl reports $!";
    try adding || die on each of the lines you suspect is failing. this construct is so much your friend, it's hard to describe.
      Yep, boo is right here. However, I would suggest one additional thing:
      # use: warn "object constructed" if $obj = Module::new; $obj->brak() or warn "brak failed: ".$obj->error; # rather than print $obj->method("foo");
      because STDERR is unbuffered. I think our own japhy taught me this trick. You can also use:
      warn "the blargle flargle, $foo, is very busted!" if $DEBUG;
      so that when you are done with major development you can just set $DEBUG to 0.

      brother dep.

      --
      transcending "coolness" is what makes us cool.