The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Error checking a file from previous file size stuck1 Shell Programming and Scripting 2 12-06-2007 05:39 AM
compare file size from a output file from a script moustik Shell Programming and Scripting 7 11-07-2007 07:17 AM
command to find out total size of a specific file size (spread over the server) abhinov SUN Solaris 3 08-08-2007 03:48 AM
Strange difference in file size when copying LARGE file.. 0ktalmagik Filesystems, Disks and Memory 1 06-03-2006 04:34 PM
how to test for file existence using file size? forevercalz Shell Programming and Scripting 3 10-26-2005 07:02 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-21-2002
Registered User
 

Join Date: Jan 2002
Posts: 8
Red face 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
Forum Sponsor
  #2  
Old 01-22-2002
PxT's Avatar
PxT PxT is offline
Registered User
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
ls -l file1 file2
  #3  
Old 01-22-2002
Neo's Avatar
Neo Neo is offline
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 4,493
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......
  #4  
Old 01-22-2002
Registered User
 

Join Date: Jan 2002
Posts: 8
Red face

Quote:
Originally posted by PxT
ls -l file1 file2

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
  #5  
Old 01-23-2002
thehoghunter
Guest
 

Posts: n/a
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.
  #6  
Old 01-23-2002
Registered User
 

Join Date: Sep 2001
Location: Green Bay, WI
Posts: 66
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
Code:
$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

Last edited by oombera; 02-20-2004 at 10:23 AM.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0