Net::Ping
Net::Ping
(OP)
I can't get Net::Ping to work.
Here is my code:
-----------------------------------------------
use Net::Ping;
use Net::FTP;
$host = "hpsab4";
$timeout = 30;
use Net::Ping;
$pong = Net::Ping->new( $> ? "tcp" : "icmp" );
(defined $pong)
or die "Couldn't create Net::Ping object: $!\n";
if ($pong->pingecho($host, 30)) {
print "It works!\n";
} else {
print "You suck!\n";
}
-----------------------------------------------------
Here is the error message:
Argument "hpsab4" isn't numeric in le at /usr/share/lib/perl5/Net/Ping.pm line 78
P.S. I get the same message if I use the IP address for the host variable.
Thanks in advance.
Here is my code:
-----------------------------------------------
use Net::Ping;
use Net::FTP;
$host = "hpsab4";
$timeout = 30;
use Net::Ping;
$pong = Net::Ping->new( $> ? "tcp" : "icmp" );
(defined $pong)
or die "Couldn't create Net::Ping object: $!\n";
if ($pong->pingecho($host, 30)) {
print "It works!\n";
} else {
print "You suck!\n";
}
-----------------------------------------------------
Here is the error message:
Argument "hpsab4" isn't numeric in le at /usr/share/lib/perl5/Net/Ping.pm line 78
P.S. I get the same message if I use the IP address for the host variable.
Thanks in advance.
RE: Net::Ping
try the loopback for a start, see if you can talk to yourself first.
use Net::Ping
$host='127.0.0.1';
$p = Net::Ping->new("tcp", 2);
unless $p->ping($host){
print "$host: not reachable\n";
} else {
print "$host: sucess!\n";
}
undef($p);
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
RE: Net::Ping
The result was:
syntax error at ping.pl line 16, near "unless $p"
Execution of ping.pl aborted due to compilation errors.
Any suggestions/help?
Thanks again.
RE: Net::Ping
unless($p->ping($host)){
I missed some brackets out, sorry about that.
And, of course, there should be a semicolon after 'use Net::Ping', so:
use Net::Ping;
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.