Christopher Spears am Freitag, 9. September 2005 10.41:
> I've decided to rework my Perl script that pings a
> blade and checks for nrnode:

use strict;
use warnings;

> my @bladeNumbers = @ARGV;

> if (scalar @bladeNumbers == 0) 

unless (@bladeNumbers)

(A list is evaluated in scalar context when used in a condition)

> { 
>     print "No blades entered!\n";
>     exit;
> }

> foreach $_(@bladeNumbers) {

foreach (@bladeNumbers) {

($_ is implicitly used)

>    my $blade = "blade-".$_;
>    print "$blade\n";
>    my $badPing = "Destination Host Unreachable";
>
>    if (`ping $blade` =~ /$badPing/) {print "$blade:
> $badPing\n";}

ping pings continuously, the backticks won't return until you add the -c 
option, e.g.

`ping -c2 $blade`

I would call ping with the absolute path.

Or even better, use module Net::Ping:

           use Net::Ping;

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

>    my $nrnode = `ssh $blade ps aux | grep nrnode`;
>    if ($nrnode =~ /nrnode/) {print "Found nrnode for
> $blade!\n";}
> }
>
> The problem line is:
>
> if (`ping $blade` =~ /$badPing/) {print "$blade:
> $badPing\n";}
>
> How do I go about finding out if the blade I ping is
> not sending back the packets?  From what I can gather,
> ping returns a success regardless of whether or not
> packets are received.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to