Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks- I am currently using the following code to FTP files from a "loc"(given as an option to the script) to /mnt,currently the script copies the files to be FTP'ed locally and then FTP's,is there a way I can FTP the files from "loc" without copying locally?
#!/usr/bin/perl -w use strict; use warnings; use Cwd qw(getcwd); use File::Copy; use File::Find; use Net::Telnet; use Net::FTP; my %options=(); GetOptions (\%options, 'loc=s') or die("\nERROR:Invalid Option\n"); my $location= $options{loc}; my %files = map {$_ => 1} qw(data.txt scripts.pl); find(sub { copy($File::Find::name, $cwd) or die "Can't cp $File::Find:: +name: $!" if (delete $files{$_}); }, $location); $ftp = Net::FTP->new("129.186.0.100", Debug => 0) or die "Cannot connect to the target: $@"; $ftp->login("root","root") or die "Cannot login ", $ftp->message; $ftp->cwd("/mnt/data") or die "Cannot change working directory ", $ftp->message; $ftp->binary(); $ftp->put("data.txt") or die "put failed ", $ftp->message;; $ftp->put("scripts.pl") or die "put failed ", $ftp->message; $ftp->quit();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is there a way to transfer files without copying to local directory
by InfiniteSilence (Curate) on Apr 23, 2011 at 18:27 UTC | |
|
Re: Is there a way to transfer files without copying to local directory
by wind (Priest) on Apr 23, 2011 at 19:38 UTC |