in reply to How to share records between ftp servers?

A bit of caution from personal experience:

Net::FTP does work, but it's a bit limited. Net::FTP::Recursive solves a few of the problems, but not all. I just had a case where I was fetching 16000+ small (8-15Kbytes) files from a WinNT server on a network with varying loads to a FreeBSD server on which the script resides. It took several hours with Net::FTP and failed to fetch a number of files. It was trying to create a new connection for each file transfer, and timing out with 'Unable to close connection' as its warning on STDERR.

When I manually FTP'd the files, the mget operation took less than 15 minutes, and all the files came across. Seeing this, I dug into man ftp. In there, I discovered (actually, rediscovered: I had done this before on an embedded system) that you can have ftp read its login and command sequence from a file.

From Perl:
use strict; use warnings; # ... chdir('/path/to/put/files/in'); system('ftp', '-N', 'mystartfile', 'ftp.server.com') && die "FTP FAI +LURE: $!\n"; chdir('/where/I/was/before'); # ...
the file mystartfile:
machine ftp.server.com login me password somesillypw binary cd /path/to/fetch/from mget * bye
This code has your Perl program waiting for completion of the FTP transfer. If this is not necessary, write the system command like so:
system('ftp -N mystartfile ftp.server.com &') && die "Couldn't start f +tp transfer: $!\n";

Replies are listed 'Best First'.
Re^2: How to share records between ftp servers?
by Doyle (Acolyte) on Oct 10, 2005 at 18:48 UTC
    Questions: My cgi program is on one ftp server and I want to copy a file to a ftp remote server programmatically. I have the IP address of the remote server, will I need the path to the folder I want to copy the file to?
      Yes, you will want to change the cd line in mystartfile and change the machine line to reflect your IP address. You will also want to change the mget line to put myfile. If you want more flexibility than this, please read man ftp.