in reply to Re: Rename all files on remote server to *.bak recursively
in thread Rename all files on remote server to *.bak recursively

Actually, we are talking about over 50 remotes, so this might not be practical. But thanks.
  • Comment on Re^2: Rename all files on remote server to *.bak recursively

Replies are listed 'Best First'.
Re^3: Rename all files on remote server to *.bak recursively
by salva (Canon) on Jun 06, 2014 at 14:32 UTC
    Then you can run then in parallel combining Net::OpenSSH::Parallel and Net::SFTP::Foreign:
    # untested my @host = ...; my $dir = ...; use Fcntl ':mode'; use Net::OpenSSH::Parallel; use Net::SFTP::Foreign; my $pssh = Net::OpenSSH::Parallel->new; for my $host (@host) { $pssh->add_host($host); } sub sftp_rename { my ($label, $ssh) = @_; my $sftp = $ssh->sftp; $sftp->find($dir, ordered => 1, wanted => sub { my (undef, $entry) = @_; if (S_ISREG($entry->{a}->perm)) { my $fn = $entry->{filename}; $sftp->rename("$fn", "$fn.bak"); } 0; }, ); } $pssh->all(parsub => \&sftp_rename); $pssh->run;
Re^3: Rename all files on remote server to *.bak recursively
by soonix (Chancellor) on Jun 06, 2014 at 09:55 UTC

    those 50 remotes can work in parallel, which to me is an argument in favour of having the remotes do the work independently (of course, your local host probably is a multitasking System, too, but ...)