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

Hi monks, I am fixing a bug where my ftp client application downloading a file from remote server, the downloading somehow failed at the midst. I checked the file size, it was half or less than the original file size. I have no idea what was happen, anyone experience it ?

Replies are listed 'Best First'.
Re: FTP downloading failed
by bobn (Chaplain) on Jun 25, 2003 at 04:16 UTC
    You posted no code.

    You posted no logs or error messages your code produced.

    How did you expect anyone to be able to help you? We are programmers, not mind-readers.

    --Bob Niederman, http://bob-n.com
      Thank you for reminding me for that. here are my code, very straight forward:
      my $ftp = Net::FTP->new($input->{remote_ip}, Debug => 0, Timeout => 8) +; $ftp->login($input->{remote_login}, $input->{remote_password}) or push + (@$error_minilog, "Cannot login to repository: Invalid login or pass +word"); $ftp->type('I'); $ftp->cwd($input->{remote_path}) or push (@$error_minilog, "Cannot cha +nge repository path"); my $ftpret = $ftp->get("filename", "localfilename") or push (@$error_m +inilog, "Failed to download file");
      I try to print the $ftpret, it was null.
        Well, it looks like even if any of new() login() type() cwd() methods fail, you will continue with the process (having diligently saved messages to @$error_minilog). So you should a) stop if any of the prerequsites fail and b) print out @$error_minilog to see what happened.

        However, since you get part of the file, the pre-reqs are probably working (though if cwd() failed you may not be getting the file you think you're getting). The doc says a null return means the operation failed, which confirms the get() fails.

        Several possibilities suggest themselves to me:
        1. There is a network flakiness between you and the ftp server, which you might test manually using an ftp client or,
        2. whatever the reason for the problem, you have a better chance of seeing it with Debug => 1 or some other positive value in new(). or
        3. cwd() failed and a shorter file of the same name exists in the directory you are left in.


        --Bob Niederman, http://bob-n.com