Server ping?

Hey guys/gals,
I need help getting this to work, my debugger gives me

"Can't locate object method "new" via package "Net::Ping" at script line 42.

Can you help me figure this out? Below is what I have so far not including all the variables.

Thanks a bunch!
William


## Ping the server and send the email if needed. ##
use Net::Ping;
$p = Net::Ping->new($proto, $timeout, $bytes);
$p->ping($serverip, $timeout);
$p->close();

if ($p eq "1") {
      print "I'm still tickin'\n";
}
elsif ($p eq "0") {
    open (MAIL, "|$mail_prog -t");
    print MAIL "To: $email\n";
    print MAIL "Reply-to: Your Server\n";
    print MAIL "From: Your Server\n";
    print MAIL "Subject: Help Me!\n";
    print MAIL "\n\n";
    print MAIL "This is your server at \$serverip. Something is wrong! Help Me!\n" ;
    print MAIL "\n\n";
    close (MAIL);
}
exit;

wglennAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

marko020397Commented:
It looks like Net::Ping package does not work. What do you have
in $proto, $timeout and $bytes variables. Did you fill them with
appropriate values. If you don't know what these variable are
for then delete them. The program will work without them too.
0
guadalupeCommented:
What about a work around.  This code will directly use the OS ping.  You just might want to check your version of ping (as it might be different from mine) to see if the "number of pings" switch is the same.

In windows just type "ping"
 at a dos prompt, in Unix type "ping -h" at a prompt...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
guadalupeCommented:
Sorry I forgot the code!!!!!!

#!/usr/local/bin/perl

######################Windows version
#n set number of pings -n 4 means four pings
$info = `ping -n 4 www.uol.com.ar`;

if ($info =~ /bytes/i)
{
      print "Alive!\n";
}
else
{
      print "Dead.\n";
}


###########Unix
#c sets number of pings
$info = `ping -c 4 www.uol.com.ar`;

if ($info =~ /bytes/i)
{
      print "Alive!\n";
}
else
{
      print "Dead.\n";
}
0
wglennAuthor Commented:
Thanks for the great help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.