Well, the wget is a solution to what I needed to do, and works fine, but for myself, I'm still trying to figure it out with Net::FTP. This is what I have so far as far as code goes:
#!/usr/bin/perl use warnings; use strict; use Net::FTP; my $ftp; #Net::FTP object my $is_error = 0; my $conn_success = 0; print "<?>~ Enter FTP Host: "; my $hostname = <STDIN>; chomp($hostname); while($conn_success != 1) { $ftp = Net::FTP->new($hostname,Timeout => 60, Passive => 1) or + $is_error = 1; if($is_error){ print "<!>~ Couldn't connect to $hostname."; } print "\n<->~ Connected to $hostname"; print "\n<?>~ Enter FTP username: "; my $username = <STDIN>; chomp($username); print "\n<?>~ Enter FTP password: "; my $password = <STDIN>; chomp($password); print "Trying to connect with\n <->Username: $username\n <->Pa +ssword: $password\n"; $ftp->login("$username","$password") or $is_error = 1; if($is_error){ print "\n<!>~ Login Failed!\n"; } else { print "<->~ Login Successful\n"; } $is_error = 0; $conn_success = 1; } $ftp->binary; file_dload($ftp->ls); $ftp->quit; sub file_dload { my @files = @_; foreach my $file(@files){ $ftp->get($file); #insert recursion for directories here } }
My biggest hurdle here is I can't figure out how to code it so the ftp connection differentiates between the directories. I was thinking of using $ftp->dir and regular expressions to match entries that start with drwx, etc. But I'm not sure how I would cut that entry in my array from drwxr-xr-x 12 owner group 1536 Aug 4 13:07 dir_name to just have the dir_name, then I could just $ftp->cwd(dir_name) and start the recursive call to the subroutine

In reply to Re^2: Net::FTP Question by MFDoom
in thread Net::FTP Question by MFDoom

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.