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

Thank you all. The code above works to FTP files from one server to another FTP server and then compares the size of the source and destination file.

Replies are listed 'Best First'.
Re: Problems getting FTP file size
by iburrell (Chaplain) on Oct 22, 2003 at 19:26 UTC
    Have you tried turning on debugging to see the communication with the server?
    my $ftp = Net::FTP->new($host, Debug => 1);
    The main thing to look at is what command Net::FTP is using to get the size and what the server returns for that command. Newer FTP servers support the SIZE and STAT command which are more reliable than doing a directory listing and parsing the results. Especially since the format for directory listing is not standardized. If the FTP server is running on something other than Unix, it is quite possible that the dirctory listing doesn't contain the size or doesn't contain it in the right place.

    Try connecting to the ftp server manually. Try doing a SIZE command or STAT command to see if it supports it. Try doing a "dir" and see what the format looks like.

Re: Problems getting FTP file size
by Roy Johnson (Monsignor) on Oct 22, 2003 at 19:07 UTC
    my $dest_file ||= $source_file;
    This is nonsense, but that's just a side note.

    Perhaps your problem is latency? Try a
    sleep 5;
    or so before the size test.

      Thanks for the "nonsense" note and the other advice. But keep in mind I started coding in perl only two weeks ago.
        Thanks for the "nonsense" note and the other advice. But keep in mind I started coding in perl only two weeks ago.
        I believe nonsense does not depend on programming language. You're declaring a variable and initializing it at the same, but checking to see that it doesn't already have a value. How can it already have a value if it hasn't been declared before?
Re: Problems getting FTP file size
by Plankton (Vicar) on Oct 22, 2003 at 15:18 UTC
    What size did you expect to see? Maybe the file is zero bytes?

    Plankton: 1% Evil, 99% Hot Gas.
      the file size is close to 1 MB. But i tried putting in different files and still get the size returned at '0'.