/usr/bin/ftp-cp is in ncbi-entrez-direct 7.40.20170928+ds-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #!/usr/bin/perl -w
# Usage: ftp-cp SERVER PATH FILE...
use strict;
use Net::FTP;
my $server = shift;
my $dir = shift;
my $ftp = new Net::FTP($server, Passive => 1)
or die "Unable to connect to FTP server: $!";
my @failed = ();
sub fetch {
my $fl = shift (@_);
if (! -e $fl) {
if (! $ftp->get($fl) ) {
my $msg = $ftp->message;
chomp $msg;
push (@failed, "$fl ($msg)");
}
}
}
$ftp->login or die "Unable to log in to FTP server: ", $ftp->message;
$ftp->cwd($dir) or die "Unable to change to $dir: ", $ftp->message;
$ftp->binary or warn "Unable to set binary mode: ", $ftp->message;
if (@ARGV) {
# file names on command line
for (@ARGV) {
fetch ($_)
}
} else {
# read file names from stdin
while (<> ) {
chomp;
$_ =~ s/\r$//;
print "$_\n";
fetch ($_)
}
}
if (@failed) {
my $errs = join ("\n", @failed);
print STDERR "\nFAILED TO DOWNLOAD:\n\n$errs\n";
exit 1;
}
|