hibernian has asked for the wisdom of the Perl Monks concerning the following question:
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 ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::FTP Bad File Descriptor - Much Weirdness
by gbarr (Monk) on Dec 03, 2001 at 18:23 UTC | |
by hibernian (Acolyte) on Dec 03, 2001 at 19:54 UTC | |
|
Re: Net::FTP Bad File Descriptor - Much Weirdness
by hibernian (Acolyte) on Dec 03, 2001 at 17:18 UTC | |
|
Re: Net::FTP Bad File Descriptor - Much Weirdness
by Fastolfe (Vicar) on Dec 03, 2001 at 22:20 UTC | |
by hibernian (Acolyte) on Dec 05, 2001 at 19:50 UTC | |
by Fastolfe (Vicar) on Dec 05, 2001 at 23:25 UTC | |
|
Re: Net::FTP Bad File Descriptor - Much Weirdness
by scain (Curate) on Dec 03, 2001 at 21:51 UTC | |
by hibernian (Acolyte) on Dec 05, 2001 at 19:58 UTC |