Dearest Monk collective,

Having a trifle bit of hassle with Net::FTP and it's reluctance, on seemingly random occasions, to delete remote files. Let's have a looksie at some code, shall we?:

sub get_file { # Similar system to sending the file over. Give it a # different name when downloading incase it is parsed whilst # only partially loaded. my $file = shift; my $tmpfile = "DOWNLOADING-".$file; my $size_remote; my $size_local; $tabspaces++; logger("Downloading $file as $tmpfile"); # Get size of the remote file that we wish to download. $size_remote = $ftp->size($file) or drop_dead("Could not obtai +n size of $file - $!"); logger("Size of $file is $size_remote"); $ftp->get($file,$tmpfile) or drop_dead("Error downloading $tmpfile - $!"); $size_local = -s $tmpfile; if ($size_local != $size_remote) { drop_dead("File size differs ( $size_remote <-> $ $siz +e_local) - Error in download"); } else { logger("Successful download ..."); } logger("Renaming local $tmpfile as $file"); rename($tmpfile,$file) or drop_dead("Could not rename local $tmpfile to $file + - $!"); logger("Deleting remote file $file"); $ftp->delete($file) or drop_dead("Could not delete remote $file - $!"); $tabspaces--; }
Nine times out of ten, this works with no problems. Ten times out of ten, the file is downloaded. The problem is with the delete() operation. Occasionally this fails, Net::FTP coming back with the utterly distressing "Bad File Descriptor", which makes faff all sense to me. I could understand the problem had I not been able to get() the file originally, but that is downloaded without any issues.

Have I a flaky Net::FTP?

Big thanks in advance for your offerrings of advice ...


In reply to Net::FTP Bad File Descriptor - Much Weirdness by hibernian

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.