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.

In reply to Re: Moving files between FTP servers by crutan
in thread Moving files between FTP servers by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.