Commit 185ba2fd authored by Gavin Brown's avatar Gavin Brown

use sftp and run in batch mode which is better when you have lots of files

parent 8402bd4d
......@@ -5,6 +5,7 @@ use Config::Simple;
use Getopt::Long;
use POSIX;
use Pod::Usage;
use IPC::Open2;
use Sys::Syslog qw(:standard :macros);
use strict;
......@@ -37,28 +38,34 @@ closedir(DIR);
syslog(LOG_DEBUG, scalar(@files)." files to copy");
my ($IN, $OUT);
my $pid = open2($IN, $OUT, sprintf(
' -b', '-',
'-o', sprintf('IdentityFile="%s"', $config->{'cp.key'}),
sprintf('%s@%s', $config->{'cp.user'}, $config->{''}),
syslog(LOG_DEBUG, sprintf('connected to %s', $config->{''}));
printf($IN "cd '%s'\n", $config->{''});
foreach my $file (@files) {
if (!system(
'-o', sprintf('IdentityFile="%s"', $config->{'cp.key'}),
)) {
syslog(LOG_CRIT, "Error copying $file: $!");
} else {
syslog(LOG_DEBUG, "File $file copied to $config->{''}");
printf($IN "put '%s'\n", $file);
while ($OUT) {
syslog(LOG_DEBUG, $_);
waitpid($pid, 0);
syslog(LOG_DEBUG, "done");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment