[EMAIL PROTECTED] writes:

> I have a Perl script, using Net::Ping, etc., and it doesn't seem
> to be working. I am not a PERL guru, obviously.
>   my $rtn = $pg->ping(\$sname);
> returns zero.

You might want to verify that the target is running a TCP echo server.
(this is how this module by default checks for connectivity -- it
*can* use ICMP/ping if you specify this)

If "telnet <targetHostname> echo" doesn't return anything this might
be the cause of the problem.

Why is this module using TCP to check ping status instead of ICMP?
Because doing ICMP requires a raw socket, and this requires root
access, that's why.  And you simply can't access raw sockets on some
brain-dead platforms.

>   my $saddr = gethostbyname($sname);

This function returns an array in an array context.  But you have a
scalar context here.

You might want something like this instead:

($a, $b, $c, $d) = unpack("C4", scalar(gethostbyname("your-host-name")))

Read the documentation for gethostbyname() for more details.

>   printf "\n%s: 0x%X\n", $sname, $saddr;
>   if ($saddr == 0) {
>     print "address is zero\n";
>   }
>   else {
>     printf "Actual address is:$i\n", $saddr;
>   };
> 
> says the address is zero.

Weird, but...

> In bash, ping works fine.
> What am I missing? What does Perl need that ping doesn't?

> Do they use different services to get the info?

Probably yes.


In the future, please post complete code segments, because it's
impossible to help you out any more with what you've posted.

--kevin
-- 
Kevin D. Clark          |                           |  Will hack Perl for
[EMAIL PROTECTED] | [email protected] | fine food, good beer, 
Cabletron Systems, Inc. | PGP Key Available         |      or fun.
Durham, N.H. (USA)      |                           |


**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to