ChrisR has asked for the wisdom of the Perl Monks concerning the following question:

I have a simple script which uses Net::FTP to connect to NAI's site and download various updates. The script works but I have a question about a warning/error that intermittently shows up. The message is:
Unable to close datastream at script.pl line 92
Line 92 is:
$ftpmsg = $ftp->get($listing{$x}[$y][0],"/$path1/$path2/$x/$listing{$x +}[$y][0]");
The only problem caused by this is emotional distress because I don’t have any idea what I might be doing wrong to cause this warning. Here is a small snippet of the code:
… $ftp = Net::FTP->new("ftp.nai.com", Debug => 0) or die "Cannot connect + to ftp.nai.com: $@\n"; $ftp->login("anonymous","user\@domain.com") or die "Cannot login to ft +p.nai.com: " . $ftp->message . "\n"; $ftp->binary() or die "Cannot change to binary data format: ". $ftp->m +essage() . "\n"; … $counter = 0; do { $counter++; $ftpmsg = $ftp->get($listing{$x}[$y][0],"/$path1/$path2/$x +/$listing{$x}[$y][0]"); } until ($ftpmsg eq "/$path1/$path2/$x/$listing{$x}[$y][0]" || + $counter >= 10); …
Any information would be greatly appreciated.

Thanks,
Chris

Update:
I looked at the code for Net::FTP and found this at the end of the get subroutine:
unless ($data->close()) # implied $ftp->response { carp "Unable to close datastream"; return undef; }
Since it uses carp instead of croak, I'm pretty sure that this is a warning and not an error. However, I'm still not quite sure what this means. It appears to me, a relative novice, that the file was downloaded but since the connection could not be closed, the routine returns undef which tells me the download failed even though the file is probably intact. Is there a way to fix this or do I just have to learn to live with it?

Replies are listed 'Best First'.
Re: Unable to close datastream
by diakonos (Hermit) on Jun 29, 2004 at 19:13 UTC
    Kinda shocked that no-one replied to this post. Here is a couple of thoughts. First, take a pill on the stress. Life is too difficult to let something like this cause heart problems ;)

    My second thought is that you may be dealing with a different type of ftp service that on the remote end than expected. There are definately compatibility issues between vendors. Just doing a manual ftp can show you these.

    Third, the carp is a warning and usually resulted from an unexpected error. The script obvioulsy finished with the data you needed by your comments. So, if you are getting the data you want, grab the remote control for an hour or two.. Have fun,