Cody Pendant:

Short answer: I'd use your first suggestion. You might also want to lookup Net::FTP::AutoReconnect. (I found it when looking up Net::FTP for my answer below.)

Details: I had a similar problem a couple of years ago. I was using FTP to get files from our mainframe, and it would time out your connection if it detected two minutes of idle time. Unfortunately, sometimes the tape robot would take more than two minutes to get the file.

So I created a subroutine that would accept a list of files to get. If anything failed, I'd detect it, close the connection and open a new one. I'm going from memory (and the Net::FTP page), but it went something like:

#/usr/bin/perl -w use strict; use warnings; my $host; my $uid; my $pwd; my $ftph; my %FList = ( 'BCLR7650(-1)' => 'BCL.SDBA.TRANSFER', 'BCLR7651(-1)' => 'BCL.SDBA.TRANSFER', 'BCXD5001(-1)' => 'BCL.SDBA.OUTGOING', ); &GetFiles(%FList); sub Connect { my $ftph = Net::FTP->new($host) or die "Can't connect"; $ftph->login($uid,$pwd) or die "Can't login!"; } sub GetFiles { my $cntFails=1; while ($cntFails>0) { $cntFails=0; &Connect; for my $FName (keys %FList) { next if !defined $FList{$FName}; print "Getting $FName from $FList{$FName}\n"; if ($ftph->cwd($FList)) { if ($ftph->get($FName)) { $FList{$FName} = undef; } else { ++$cntFails; } } else { ++$cntFails; } } $ftph->quit; } }
It went something like that. Yes, it used crappy global variables and such. (And the directory hierarchy on the mainframe *is* goofy, as it uses "." as directory separators. Yechh!). But at least it got the job done (Unless, of course, you spelled a directory or file name wrong. It was single-minded in it's determination, and would try all night long, trying to get the file.)

--roboticus


In reply to Re: Large FTP task by roboticus
in thread Large FTP task by Cody Pendant

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.