ftp file size


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users ftp file size
# 1  
Old 01-21-2002
Power 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
# 2  
Old 01-22-2002
ls -l file1 file2
# 3  
Old 01-22-2002
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-23-2002
Power

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
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.
thehoghunter
# 6  
Old 01-23-2002
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 01:23 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

FTP zero size file

Hi AM using unix Aix Ksh I need to clarify regarding sending the zero size file to another server. VAL=ftp.sh -c put souce_file Dest_file $1 $2 $3 $4 $5 $VAL 2 > $ERR When am Sending the Zero Size File getting alerts netout write returned Zero. But i would like to know $VAL... (4 Replies)
Discussion started by: Venkatesh1
4 Replies

2. Shell Programming and Scripting

FTP a huge Size file

Dear All, Good Evening!! I have a requirement to ftp a 220GB backup file to a remote backup server. I wrote a script for this purpose. But it takes more than 8 hours to transfer this file. Is there any other method to do it in less time??? Thanks in Advance!!! ---------- Post updated... (5 Replies)
Discussion started by: Naga06
5 Replies

3. Shell Programming and Scripting

Checking the size of a file after FTP

Hi I am doing a FTP process through which I am copying a file from my local server to Remote server. After this I want to check the size of the file Below is my program: LOCALDIR=/batch/ediprocess REMOTESERVER=test.appl.com REMOTEPATH=batch/ftpTest LOGIN=px PASSWORD=abcd ftp -n... (3 Replies)
Discussion started by: shanth_chandra
3 Replies

4. Shell Programming and Scripting

How to check file size before and after FTP

I want to trasfer file from 1. Unix server A to server B 2. Unix server A to windows directory Is there a way to check the size before and after FTP. I want to check the size of the file in server A before FTP and in server B after FTP in case 1 In case 2 I want to check the size of... (1 Reply)
Discussion started by: i.scientist
1 Replies

5. Shell Programming and Scripting

size of a file that iam ftp ing

Hi, I want to compare the size of the files in my local machine before ftp ing it and the size of the file in the remote machine i.e after ftping . SO that the ftp is successful . (3 Replies)
Discussion started by: dineshr85
3 Replies

6. Shell Programming and Scripting

How to compare file size after ftp?

Is possible if I want to campare file size on source and destination after ftp transfer? If anybody know, please explain to me. (1 Reply)
Discussion started by: icemania
1 Replies

7. Shell Programming and Scripting

Perl FTP - check file size

The FTP perl module does not have any function which checks if the file downloaded is of size 0. Is there any way in perl to check while getting the files through FTP? Sometimes, there might be a problem with FTP and the downloaded file maybe of size 0. Hence, I would like to FTP that file... (1 Reply)
Discussion started by: rahulrathod
1 Replies

8. Shell Programming and Scripting

ftp UnixWare File Size Problem

Hi Engg. ! :cool: When I am trafering a file through ftp from windows to UNIX having size about 1.24 GB then at the end of file transfer I got a error message "Extended file size limit (coredump)" and finnally ftp stop, whenever on other UNIX server the same file from windows... (1 Reply)
Discussion started by: Niraj Gopal Sha
1 Replies

9. Shell Programming and Scripting

send file of size 0 with FTP on AIX

I'm using IBM AIX 5.2 to send file with ftp to other unix machine. The command is into a shell: ... ftp -n > outFtp 2> errFtp <<PARAM open $2 user $3 $4 put $1 $remote bye PARAM ... then i look at the size of errFtp and outFtp to see if there are some error message.... (4 Replies)
Discussion started by: gggarb
4 Replies

10. UNIX for Dummies Questions & Answers

ftp hangs on file size = 0

I have an ftp process which runs every 10 minutes between Unix and an NT box. Normally it works, but when the script tries to get a file from NT that has a length of 0, the ftp process hangs (as if it is still waiting for the end of the file). This is the script... (3 Replies)
Discussion started by: mheinrich
3 Replies
Login or Register to Ask a Question