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?:
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.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--; }
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |