Check file size before and after scp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check file size before and after scp
# 1  
Old 12-13-2012
Check file size before and after scp

Dears does anybody know how to check the file size on server A and server B before and after scp using KSH. Script should be on server A.

I will be using it for the below mentioned scenario:

I have written a code to fetch files from server A, move it onto server B compress it and save it on server C and delete the files from server A and B.

But now my concern is to check the size and filename before deleting from server A and B.. the checks are required between server A and server B before deleting from server A & between server B and server C before deleting from server B. The code is running on server B......



Code:
#########

FILELIST=`ssh root@ServerA 'find /dir1/dir2 -type f -print -mtime +12'`
for f in $FILELIST

do
dirname=`basename $f`
mkdir -p /CGW_Backup/egcdr/`echo ${dirname:0:6}`
scp -r usn@serverA:$f ServerB`echo ${dirname:0:6}`
done


#checking file name and sizes betwen server A and B




LOCAL_FILELIST=`find ServerB`
for f in $LOCAL_FILELIST
do
bzip2 -9 $f
done



scp -r ServerB/* usn@ServerC:/mnt/pools/A/A0/Backups/


#checking the file name and sizes for between server B and server C


for f in $FILELIST
do
removing the files from CG and Hstore
`ssh usn@serverA 'rm $f'`
done

rm -r /serverB/*


Last edited by Scrutinizer; 12-13-2012 at 03:24 AM.. Reason: code tags
# 2  
Old 12-18-2012
You can parse the ls -l output with read:
Code:
ls -l xxx|( #subshell required in bash
read perms links fuser fgroup fsize fd1 fd2 fd3 fname ; echo $fsize )

# 3  
Old 12-20-2012
Issue is solved using rsync (powerful tool)... it does the required task automatically.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File size check

I am trying to check whether two files are empty or not using below if condition but its checking for only one file if ] Again I tried if && ] Need your assistance (2 Replies)
Discussion started by: Aditya_001
2 Replies

2. Shell Programming and Scripting

Check a file size

I'm doing a script thats check if mylogfile.log is bigger then 5000 but i dont know how to write it. thanks in avance. (6 Replies)
Discussion started by: Froob
6 Replies

3. Shell Programming and Scripting

Script to check for the newest file mutiple times a day and SCP it to another server.

Hi, I need a sample of a script that will check a specific directory multiple times throughout the day, and scp the newest file to another server. Example: current file is misc_file.txt_02272011 (the last part is the date), once that has been secure copied, another one may come in later the... (1 Reply)
Discussion started by: richasmi
1 Replies

4. Shell Programming and Scripting

check the file size

if ; then cp /tmp/testfolder/*.* ~/new/logs/ else echo "No files today" exit fi The problem is this doen't work when there is more than 1 file. Please tell me how to take the latest file and check the size of the file in a directory (1 Reply)
Discussion started by: sandy1028
1 Replies

5. Shell Programming and Scripting

Check the file size - help

I want to write a batch job (ksh) with the following requirement we have file feeds coming to our system from other team, if the file size is greater than expected then we dont need to process the file for the day and need to archive the file and send email notification to the manager saying... (5 Replies)
Discussion started by: sithara
5 Replies

6. Shell Programming and Scripting

Check for file size is zero or not.

I have following script on AIX/KSH if ] ; then echo "filename exists and is > 0 bytes" else echo "filename does not exist or is zero length" fi It is not working. What is wrong here??? (3 Replies)
Discussion started by: Hangman2
3 Replies

7. Shell Programming and Scripting

To check file size

Hi All, I am in small problem.. i have one script which transfers some big files to my ftp usign normal command like put .... my problem is how to check whether my file have been transferred successfully on ftp or not... i know only inside ftp we have option like 'size' command which... (2 Replies)
Discussion started by: Shahul
2 Replies

8. UNIX for Dummies Questions & Answers

file size changed after SCP

Hi All, I am having a scriptin that the SCP command is performed . The scp is transfering one file from one location to other. But after SCP i see the file size is changed from original size . What might be the reason. Thanks in advance, Arunkumar (11 Replies)
Discussion started by: arunkumar_mca
11 Replies

9. Shell Programming and Scripting

file size check

How can I perform size check of any character file(which switch)? For example: I have to perform certain actions if file size is not zero. How can I do that? Is this syntax fine? if test ! -z $filename then fi (2 Replies)
Discussion started by: malaymaru
2 Replies

10. UNIX for Dummies Questions & Answers

Check file size

I need a unix script that will check the size of multiple files in the same directory or from a text file. (6 Replies)
Discussion started by: alnita
6 Replies
Login or Register to Ask a Question