Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Moving files between FTP servers

by crutan (Novice)
on Nov 09, 2000 at 22:37 UTC ( [id://40769]=note: print w/replies, xml ) Need Help??


in reply to Moving files between FTP servers

This is a script that does just that, it opens two connections and moves files between them.

It does bring the file down to the local disk, though, so it may not be what you want.

#!/usr/bin/perl -w use strict; use Net::FTP; use FileHandle; ### # A Script that will get files from one server object # stored in $ftp_a and put them onto a second server # object, $ftp_b. # # Objective is to do this using filehandles, and not # actually writing to disk. ### ### # File list. Generate however you want. ### my @file_list = ("some.file"); ### # Begin by opening the connections to the two servers # and logging in. ### my $ftp_a = Net::FTP->new("first.server.address", Debug => 0); my $ftp_b = Net::FTP->new("second.server.address", Debug=> 0); $ftp_a->login("first_server_username","first_server_password"); $ftp_b->login("second_server_username","second_server_password"); my $fh = FileHandle::new; foreach (@file_list) { $ftp_a->get($_,$fh); $ftp_b->put($fh,$_); unlink($fh); } $ftp_a->quit; $ftp_b->quit;
PS:
Does anyone know how to open a filehandle or filehandle-like object that Net::FTP can stream its data to? Like:
get(remote_file,(put process on other server));
I tried it with open $fh, "$ftp_b->put($_)"; but that didn't work.

Replies are listed 'Best First'.
Re: Answer: Moving files between FTP servers
by I0 (Priest) on Dec 26, 2000 at 06:48 UTC
    see the pasv_xfer command in Net::FTP

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://40769]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-19 07:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found