ftp file size

how to compare file size which has been received through ftp get from a remote location with local copy available any clue

regards

ls -l file1 file2

diff -lines file1 file2

... might work for you also.....

Did you do a man on diff and find anything of interest?

I normally use PxT's suggestion of ls -l file1 file2 but you might find something creative with diff......

how to do this for a remote file in a remote ftp site and to the same file which has been transfered . after transfeting i want to compare with the original file

thanks

Although I don't know if this will help you but when sending a single file (HP Openview maps) every night I do the following.

One cron job gathers the files into a tar file (which is then compressed). Then the file size of that file is sent to another file
file1.tar (contains maps)
file2.dat (contains size of file one)
This is done via # ls -s file1.tar > file2.dat

Another cron job then runs (starts one minute after the first and waits for the file2.dat to be created) and sends both files to the different systems. Each of those systems have a cron job waiting for the file2.dat - this is done to insure that file1.tar (which is sent first in the script) is completely done via the ftp (I don't have to get cute in opening a file to see if it's done downloading).
I can then cat file2.dat and get the file size expected and compare it to the file1.tar file size using the same command ls -s.

system1 - tar files > file1.tar
system1 - compress file1.tar
system1 - ls -s file1.tar.Z |awk '{print $1}' > file2.dat
system1 or system2 ftp files
system2 Create script to compare output of ls -s file1.tar.Z |awk
'{print $1}' with info in file2.dat

This may be a royal pain if you have a bunch of these to do, but tar and compressing into one file may help. Good luck.

not sure if this is an optiopn for you but perl Net:FTP has functionality to do what you want, this script gets the size and then sleeps for a minute and checks again to make sure I don't grab the file in mid transfer, you could easily get the local file size and then compare with the remote file size

$ftp = Net::FTP->new("ftp.domain.com");

$ftp->login("scott",tiger);
$ftp->cwd("./date_in");
@files = $ftp->ls ('data*');
chomp (@files);

foreach $file (@files){
        $fsize = $ftp->size($file);
        sleep 60;
        $f2size = $ftp->size($file);

        while ($fsize != $f2size){
                $fsize = $ftp->size($file);
                sleep 60;
                $f2size = $ftp->size($file);
        }

        $ftp->get("$file", "/h14/pmer/inter_data/$file");
        $t=new Net::Telnet(Timeout => 60 );

added code tags for readability --oombera