×
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

Net::Ping & Net::DNS help
2

Net::Ping & Net::DNS help

Net::Ping & Net::DNS help

(OP)
Help for this modules users

RE: Net::Ping & Net::DNS help

(OP)
Hi Mike,
How to use Net::Ping module??
I do :

$p = Net::Ping->new(

RE: Net::Ping & Net::DNS help

(OP)
How view the entire mesagge?

RE: Net::Ping & Net::DNS help

try this:

use strict;
use Net::Ping;

my $p;
my $host = 'www.ntlworld.com';

$p = Net::Ping->new('icmp');
if($p->ping($host)){
    print "$host is reachable.\n";
} else {
    print "$host is not reachable.\n";
}
$p->close();

I found that if you specify the icmp protocol (that's the standard ping protocol anyway) it works fine.

Mike
michael.j.lacey@ntlworld.com
Cargill's Corporate Web Site
Making mistakes, so you don't have to. <grin>

RE: Net::Ping & Net::DNS help

(OP)
How to use Net::Ping module??
I do :

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

with a reacheable $host and not print "$host is alive"
in a Linux S.O.

What must be $host?

$host = 126.73.100.100 or $host = "126.73.100.100"
or  $host = 12673100100 or etc.....

I need that $host be IP address, and message "tcp"
 
I´m beginner whit Perl, but not beginer programmer and need
work with this modules, help please.
Thanks

RE: Net::Ping & Net::DNS help

(OP)
Mike:

I need root permision for execute with 'icmp' and not have this.

What is strict?

Thanks for you help I'm going to vote for you.
Excuse my English I´m Spanish speaker.

RE: Net::Ping & Net::DNS help

Yeah.... From perldoc Net::Ping ...

"Specifying the "icmp" protocol requires that the program be run as root or that the program be setuid to root."

I didn't pick that up before because I was running in under ActivePerl at home on Win98...

Also from perldoc Net::Ping is:

"The icmp protocol requires that the program be run as root or that it be setuid to root. The tcp and udp protocols do not require special privileges, but not all network devices implement the echo protocol for tcp or udp."

This just doesn't seem a reliable way to do things... Can't you run the command as root or call the unix ping command directly?

Mike
michael.j.lacey@ntlworld.com
Cargill's Corporate Web Site
Making mistakes, so you don't have to. <grin>

RE: Net::Ping & Net::DNS help

(OP)
I can't run the command as root, but I can call the linux ping directly . How do it?

You know what parameter $host must be ?

On "tcp" mode  
if i do $host = 'www.ntlworld.com' it work fine, but
if i do $host = '164.73.100.5' or $host = 164.73.100.5 don't work

I'm waiting you help  
Thank you


RE: Net::Ping & Net::DNS help

Hi Mac,


$host='164.73.100.5';
open(PING,"/etc/ping $host|") || die;
while(<PING>){
    print;
}

This will run the ping command and feed the results into your Perl script throught the PING handle

Mike
michael.j.lacey@ntlworld.com
Cargill's Corporate Web Site
Making mistakes, so you don't have to. <grin>

RE: Net::Ping & Net::DNS help

(OP)
Hi Mike I'm going to cosidere your example, but I want
show you my case before to leave Net::Ping module.

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

it work fine

I do:

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

it not work. Why?
What I'm doing wrong?

Your simpler method don´t work.

I´m waiting your help
You win my vote !
Thank you.

RE: Net::Ping & Net::DNS help

(OP)
Hi Mike
I solved my problem !!
You help me very much.
Zank you very much !!

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