There's always File::RsyncP::FileList, File::Rsync, URI::rsync, and File::DirSync if you want to go that route.

You might also take a look at rcopy for some other ideas, which purports to mirror two servers together.

I did something similar, using a remote webserver's directory listing of files, and presenting them to my local machine as "local" files, for users to click/download/etc. Here's an example of that, using kernel.org in this case.

Basically what this does is fetch the remote "page" of files, extract the links, calculate the file sizes, "commify" them, and prints them out. Simple. Maybe this will give you a few ideas, depending on where/how these files are found.

use strict; use LWP::UserAgent; use HTML::LinkExtor; use URI::URL qw(url); my $url = "http://kernel.org/pub/linux/kernel/v1.0/"; my $ua = LWP::UserAgent->new; $ua->agent('pps 0.1.43'); my @links = (); sub callback { my ($tag, %attr) = @_; return if $tag eq 'href'; push(@links, values %attr); return (@links); } my $p = HTML::LinkExtor->new(\&callback); my $res = $ua->request( HTTP::Request->new(GET => $url), sub {$p->parse($_[0])}); my $base = $res->base; @links = map {$_ = url($_, $base)->abs;} @links; my @krn = grep(/tar/, @links); foreach my $krn (@krn) { my @remote_files = HTTP::Request->new(HEAD=>$krn); my $resp = $ua->request(@remote_files); my $length = $resp->header('Content-Length'); my $bprecise = sprintf "%.0f", $length; my $bsize = insert_commas($bprecise); my $kprecise = sprintf "%.0f", ($length/1024); my $ksize = insert_commas($kprecise); my $archtype; # tarball? or bzip2? or zip? my $krnhref = substr($krn, 48, 70); if ($krn =~ /tar.gz/) { $archtype = "tarball"; } elsif ($krn =~ /bz2/) { $archtype = "bzip"; } else { $archtype = "zip"; } print "Path: $krn\nFile: $krnhref "; print "($archtype) - ${ksize}kb, $bsize bytes\n\n"; } sub insert_commas { my $text = reverse $_[0]; $text =~ s/(\d{3})(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; }

In reply to Re: Reading a remote Filesystem by hacker
in thread Reading a remote Filesystem by CodeJunkie

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.