Perl Ping Help

Reply

Join Date: Aug 2005
Posts: 1
Reputation: rharsha83 is an unknown quantity at this point 
Solved Threads: 0
rharsha83 rharsha83 is offline Offline
Newbie Poster

Perl Ping Help

 
0
  #1
Aug 24th, 2005
hi,
i have been asked to get the information of the systems in the network by executing ping in perl programming.

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

sample of my code is shown above

where $host--> is the ip of the destination machine. if i try to give the loopback or ip of my machine then its working properly. but if i try to give ip of the some other machine conneted to network then ping will not work.
But ping using command prompt is working properly for any machine in the network.
Is there anybody to help me out...
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 16
Reputation: kordaff is an unknown quantity at this point 
Solved Threads: 0
kordaff kordaff is offline Offline
Newbie Poster

Re: Perl Ping Help

 
0
  #2
Sep 1st, 2005
Net:ing defaults to a tcp connection to the echo port (7 according to my /etc/services file). Use this (from the Net:ing man page) example to do a regular ICMP ping like the command line:

  1. use Net::Ping;
  2. my $p = Net::Ping->new('icmp');
  3. print "$host is ";
  4. print "NOT " unless $p->ping($host, 2);
  5. print "reachable.\n";
  6. sleep(1);
  7. $p->close();

Kordaff
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1
Reputation: Jayaprabhu is an unknown quantity at this point 
Solved Threads: 0
Jayaprabhu Jayaprabhu is offline Offline
Newbie Poster

Re: Perl Ping Help

 
0
  #3
Oct 11th, 2006
Try this... Its working for me

my $a;
my $p;
use Net:ing;
$p = Net:ing->new();
$a= $p->ping("$host");
$p->close();
if( $a eq '')
{
print "Host is not alive";
}
else
{
print "Host is alive";
}


Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC