Dru has asked for the wisdom of the Perl Monks concerning the following question:
Thanks,#!/usr/bin/perl -w # Attempt to connect to the server on each interface until successfull use strict; use Net::SSH qw(ssh); my @host = qw[ 192.168.15.2 192.168.16.2 192.168.17.2 192.168.18.2 ]; my $stout; $stout = run($host[0]); if ($stout == '256'){ print "$host[0] not responding, trying $host[1]\n"; $stout = run($host[1]); if ($stout == '256'){ print "$host[1] not responding, trying $host[2]\n"; $stout = run($host[2]); if ($stout == '256'){ print "$host[2] not responding, trying $host[3]\n"; $stout = run($host[3]); } } } else{ exit; } sub run { my $host = $_[0]; my $user = 'root'; my $cmd = '/usr/local/scripts/temp.sh'; ssh("$user\@$host", $cmd); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Not Using So Many 'if' Statements
by insensate (Hermit) on Jan 09, 2003 at 19:15 UTC | |
by CountZero (Bishop) on Jan 09, 2003 at 20:34 UTC | |
by insensate (Hermit) on Jan 09, 2003 at 20:40 UTC | |
by CountZero (Bishop) on Jan 09, 2003 at 20:46 UTC | |
by Dru (Hermit) on Jan 09, 2003 at 20:29 UTC | |
|
(z) Re: Not Using So Many 'if' Statements
by zigdon (Deacon) on Jan 09, 2003 at 19:15 UTC | |
|
Re: Not Using So Many 'if' Statements
by OM_Zen (Scribe) on Jan 09, 2003 at 20:16 UTC | |
|
Re: Not Using So Many 'if' Statements
by Aristotle (Chancellor) on Jan 11, 2003 at 22:52 UTC |