×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Ping using perl

Ping using perl

Ping using perl

(OP)
I cannot get my ping program to wrok as it keeps giving me an error message like
"icmp ping requires root privelage at ping.pl line 11"

I am running it froma college server so does this mean that I have to get special permissions.

Here is the code I am trying to run.
===========================================
#!/usr/bin/perl

 use Net::Ping;


    $p = Net::Ping->new();
    print "$host is alive.\n" if $p->ping($host);
    $p->close();


    $p = Net::Ping->new("icmp");
    foreach $host (@host_array)
    {
        print "$host is ";
        print "NOT " unless $p->ping($host, 2);
        print "reachable.\n";
        sleep(1);
    }
    $p->close();
    

    $p = Net::Ping->new("tcp", 2);
    while ($stop_time > time())
    {
        print "$host not reachable ", scalar(localtime()), "\n"
            unless $p->ping($host);
        sleep(300);
    }
    undef($p);
    

    # For backward compatibility
    print "$host is alive.\n" if pingecho($host);

====================================================

 Line 11 is the "$p = Net::Ping->new("icmp");" line.

Hope you can help

RE: Ping using perl

Here's what I did to find "ping" on my Redhat 6.1 Linux machine:

   which ping

it responded with:

   /bin/ping

so I did "ls -l /bin/ping" and it told me this:

-rwsr-xr-x   1 root     root        18228 Sep 10  1999 /bin/ping

as you can see, it's owned by root, and is setuid root and executable by group(root) and world - so anyone should be able to run it, and no matter who runs it it will run "as" root because of the setuid(the "s" in the "execute" slot of owner).

"root" probably owns the icmp "ping" command that you're trying to use - and maybe the setuid bit is not set - try to find out from the admins what permissions are required to run "ping".  If they say only root can run it, and you don't have root permissions, than you might be out of luck.

HTH.


Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

RE: Ping using perl

try "$p = Net::Ping->new("tcp") instead

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close