in reply to Rename all files on remote server to *.bak recursively
I would change the approach from your script (sending a shell command loop to the remote side) to a three-step approach:
Using the three steps makes it much, much easier to review the list of commands before they are executed.
The relevant parts of the script would be:
# Get list of remote files my @remote_files= qx(ssh $uid $h 'find $dirname');
# Munge filenames to commands: my @commands= map { sprintf "mv -i '%s' '%s.bak'", quotemeta($_), quotemeta($_) } @remote_files;
# Send list of commands to the remote side: # First, a dry-run instead of actually doing that: my $remote= \*STDOUT; # Use this to actually do the remote execution: #open $remote, "| ssh -q -l $uid $h"; print { $remote } join "\n", @commands;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Rename all files on remote server to *.bak recursively
by PerlSufi (Friar) on Jun 05, 2014 at 14:01 UTC | |
|
Re^2: Rename all files on remote server to *.bak recursively
by nancylt723 (Initiate) on Jun 06, 2014 at 12:31 UTC | |
by Corion (Patriarch) on Jun 06, 2014 at 12:46 UTC | |
by nancylt723 (Initiate) on Jun 09, 2014 at 12:35 UTC | |
by salva (Canon) on Jun 09, 2014 at 12:48 UTC | |
by nancylt723 (Initiate) on Jun 09, 2014 at 15:25 UTC |