Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::Ping & Net::DNS help 2

Status
Not open for further replies.

mackiew

Programmer
Sep 15, 2000
18
0
0
UY
Help for this modules users [sig][/sig]
 
Hi mackiew,

Did you have a specific question? [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Making mistakes, so you don't have to. &lt;grin&gt;[/sig]
 
Hi Mike,
How to use Net::ping module??
I do :

$p = Net::ping->new( [sig][/sig]
 
How view the entire mesagge? [sig][/sig]
 
are you having trouble posting mack? [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Making mistakes, so you don't have to. &lt;grin&gt;[/sig]
 
try this:

use strict;
use Net::ping;

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

I found that if you specify the icmp protocol (that's the standard ping protocol anyway) it works fine. [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Making mistakes, so you don't have to. &lt;grin&gt;[/sig]
 
How to use Net::ping module??
I do :

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

with a reacheable $host and not print &quot;$host is alive&quot;
in a Linux S.O.

What must be $host?

$host = 126.73.100.100 or $host = &quot;126.73.100.100&quot;
or $host = 12673100100 or etc.....

I need that $host be IP address, and message &quot;tcp&quot;

I´m beginner whit Perl, but not beginer programmer and need
work with this modules, help please.
Thanks [sig][/sig]
 
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.
[sig][/sig]
 
Yeah.... From perldoc Net::ping ...

&quot;Specifying the &quot;icmp&quot; protocol requires that the program be run as root or that the program be setuid to root.&quot;

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

Also from perldoc Net::ping is:

&quot;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.&quot;

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? [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Making mistakes, so you don't have to. &lt;grin&gt;[/sig]
 
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 &quot;tcp&quot; mode
if i do $host = ' 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


[sig][/sig]
 
Hi Mac,

[tt]
$host='164.73.100.5';
open(PING,&quot;/etc/ping $host|&quot;) || die;
while(<PING>){
[tab]print;
}
[/tt]

This will run the ping command and feed the results into your Perl script throught the PING handle [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Making mistakes, so you don't have to. &lt;grin&gt;[/sig]
 
Hi Mike I'm going to cosidere your example, but I want
show you my case before to leave Net::ping module.

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

it work fine

I do:

$host = '164.73.155.20'
$p = Net::ping->new(&quot;tcp&quot;);
print &quot;$host is alive.\n&quot; 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.
[sig][/sig]
 
Hmmm,

well.. thanks for your confidence (and your vote) but I'm afraid I'm stumped....

does the IP address method work with udp? [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Making mistakes, so you don't have to. &lt;grin&gt;[/sig]
 
Hi Mike
I solved my problem !!
You help me very much.
Zank you very much !! [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top