Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: How to use "$ssh->before()"

by vinoth.ree (Monsignor)
on Apr 15, 2015 at 11:10 UTC ( [id://1123481]=note: print w/replies, xml ) Need Help??


in reply to How to use "$ssh->before()"

I want to know peer ip is alive or not.

If you know the peer IP addresses, use Net::Ping module to ping set of IP addresses,

Ex,

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

All is well. I learn by answering your questions...

Replies are listed 'Best First'.
Re^2: How to use "$ssh->before()"
by ww (Archbishop) on Apr 15, 2015 at 11:59 UTC

    or, alternately (because using icmp may require addtl info)...

    #! /usr/bin/perl -w use 5.018; # cf [id://1123481] -> my $p = Net::Ping->new("icmp"); # method not allowed by (some) hosts, YMMV! my @host_array = ('n+.n+.n+.n+', 'n+.n+.n+.n+', .... ); say "\n Pinging so-and-so(s)\n"; use Net::Ping; my $p = Net::Ping->new("syn"); for my $host (@host_array) { if ($p->ping($host) ) { say "Host $host is alive \n (at least, 'arguably' See doc re +'syn' protocol)\n"; } else { say "Could not ping host $host, $!"; } $p->close(); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1123481]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-28 21:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found