Re: How to share records between ftp servers?
by marto (Cardinal) on Oct 10, 2005 at 13:19 UTC
|
| [reply] |
|
|
Thanks, this was very helpful.
| [reply] |
Re: How to share records between ftp servers?
by samizdat (Vicar) on Oct 10, 2005 at 13:56 UTC
|
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";
| [reply] [d/l] [select] |
|
|
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?
| [reply] |
|
|
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.
| [reply] [d/l] [select] |
Re: How to share records between ftp servers?
by Grygonos (Chaplain) on Oct 10, 2005 at 13:20 UTC
|
| [reply] |
Re: How to share records between ftp servers?
by Zaxo (Archbishop) on Oct 10, 2005 at 18:47 UTC
|
The scp utility can copy files from one remote to another, without moving through the local machine. Net::SCP provides a Perl interface.
That's very handy if you're working through a slow connection.
| [reply] |
Re: How to share records between ftp servers?
by murugu (Curate) on Oct 10, 2005 at 13:35 UTC
|
Try Net::FTP.
Regards, Murugesan Kandasamy.
| [reply] |
Re: How to share records between ftp servers?
by ides (Deacon) on Oct 10, 2005 at 18:39 UTC
|
Just an FYI, but if you're moving files from one server to another server, you'll need to download them first to wherever your script that uses Net::FTP resides before sending them on to the recipient server.
| [reply] |
|
|
| [reply] [d/l] |
|
|
WOW! Learn something new everyday. I've been using or running FTP servers for gosh about 13 years now and never knew this feature existed. Thanks!
| [reply] |