嘗試之一,故障轉移到另一個:
#! /usr/bin/perl
use warnings;
use strict;
use Net::SCP qw/ scp /;
use Net::SCP::Expect;
my @hosts = qw/ host1 host2 host3 /;
my $user = "YOUR-USERNAME-HERE";
my $pass = "PASSWORD-GOES-HERE";
my $file = "file-to-copy";
foreach my $host (@hosts) {
my $dest = "$host:$file";
my $scp = Net::SCP->new($host, $user);
unless ($scp->scp($file => $dest)) {
my $scpe = Net::SCP::Expect->new;
$scpe->login($user, $pass);
local [email protected];
eval { $scpe->scp($file => $dest) };
next unless [email protected];
warn "$0: scp $file $dest failed:\n" .
"Public key auth:\n" .
" $scp->{errstr}\n" .
"Password auth:\n" .
" [email protected]\n";
}
}
其實,網:: SCP不支持:-( – Julien 2010-01-26 18:23:37
我試過非標準端口,它不處理這兩種情況 – Julien 2010-01-26 18:58:02