Confirm file copy


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Confirm file copy
# 1  
Old 05-23-2011
Confirm file copy

Need to check whether the source file(FTP'ed file) is completly copied or not such that I can further action on the same. I have created the below script to achieve this by checking for every 10secs to whether file size is same or not but it may create a problem if the file transfer is slow and if file size doesnt changes after 10secs , I may end up with copying the incomplete file.
Appreciate your ideas on the same.


Code:
#!/bin/ksh
file_nm=$1
no_of_tries=5
sleeptime=10
curr_file_size() {
ls -l $file_nm | awk '{print $5}'
}

if [  -f $file_nm  ]
then
no_of_tries=5
sleeptime=10
for i in `seq $sleeptime`
do
prev_file_size=`curr_file_size`
sleep $sleeptime
if  [  $prev_file_size -eq `curr_file_size` ]
then
echo file is copied completly
exit
else
echo file is being copied
fi
done
else
echo file does not exists
fi

# 2  
Old 05-23-2011
A similar post here.

https://www.unix.com/shell-programmin...hey-loads.html

The best way to know would be using a temporary extension file ftping and rename the file once completely done by ftp itself.
# 3  
Old 05-23-2011
Hi Kumaran,
Thanks for the quick reply on this, your suggestions seems to be ok but is there any other way to achieve the same as our source is not capable of creating the extension or other flag after completly copying the file.

Regards ,
Palani
# 4  
Old 05-23-2011
You will have to used fuser to check if the file is current opened by any user (here it would be ftp user). Or to use lsof..

But i think what we suggested is the best way and it is so simple, because ftp commands will provide such a facility with ease.
# 5  
Old 05-23-2011
Thanks a lot for your prompt and useful reply on this, will try to use these options.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Confirm the execution of copy command is successful or not

All, I have to copy huge file from one location to another using python . I want to make sure the execution of Copy command is successful and all the files are copied properly (there has not been any abrupt interruption to the copy process or error like no space available is encountered during... (5 Replies)
Discussion started by: IshuGupta
5 Replies

2. UNIX for Dummies Questions & Answers

Confirm the execution of Copy command is successfull or not

All, I have to copy huge file from one location to another using python . I want to make sure the execution of Copy command is successful and all the files are copied properly (there has not been any abrupt interruption to the copy process or error like no space available is encountered during... (2 Replies)
Discussion started by: IshuGupta
2 Replies

3. AIX

Need to confirm something regarding TL upgrades

Hi everyone, My current AIX OS level is "7100-01-06-1241" and I am planning to upgrade it to " 7100-02-03 ". Can i directly upgrade it to "7100-02-03" from 7100-01-06" ? or first i need to upgrade the "7100-01-06" LPAR to TL 02 and then reboot and then upgrade it to TL 02 SP03 ? ... (4 Replies)
Discussion started by: System Admin 77
4 Replies

4. Shell Programming and Scripting

Sendig a file and a confirm file

Hi, I need to send a file from one server to at a set time interval, once the file has been completely sent, it is then processed on the receiving server. Is there a way that i can send a file and know that the complete file has been sent and that there have been no errors in the transmission... (7 Replies)
Discussion started by: brunlea
7 Replies

5. UNIX for Dummies Questions & Answers

Do I need to extract the entire tar file to confirm the tar folder is fine?

I would like to confirm my file.tar is been tar-ed correctly before I remove them. But I have very limited disc space to untar it. Can I just do the listing instead of actual extract it? Can I say confirm folder integrity if the listing is sucessful without problem? tar tvf file1.tar ... (1 Reply)
Discussion started by: vivien_chu
1 Replies

6. Shell Programming and Scripting

sed - How to confirm substitution

How to confirm whether a particular substitution taken place or not ? Find the code below :- #!/bin/ksh COUNT=0 ####### Create backup of the original file ###### cp passwd passwd_old ####### Read the csv file for unixid and project ###### while IFS=, read unix_id project_id do ... (1 Reply)
Discussion started by: hiten.r.chauhan
1 Replies

7. Shell Programming and Scripting

Script to Reboot and Confirm

On my Solaris box I have to reboot some devices like below. However I think this can be done through a script. I've create a list that contains the devices IP addresses. Here's the logic: Reboot 4 devices and sleep for 5mins(300s.) While the devices are rebooting, I would like to confirm... (9 Replies)
Discussion started by: ravzter
9 Replies

8. Solaris

How can we confirm that, the disk has failed in Solaris?

Hi All, Seems to be one of the disk has failed on my Solaris server. How do i confirm that disk has really failed or not? Here are alert details. ------- iostat -En out/put c1t3d0 Soft Errors: 1884 Hard Errors: 153 Transport Errors: 54 Vendor: FUJITSU Product:... (3 Replies)
Discussion started by: Naresh Kommina
3 Replies

9. UNIX for Dummies Questions & Answers

Confirm job execution

Hello everybody, Can anybody tell me how do we comfirm the execution of a scheduled job ? In other words, how do I know whether my scheduled script is being executed or not ? Thanks Jitu JK (2 Replies)
Discussion started by: jitu.jk
2 Replies

10. Shell Programming and Scripting

Confirm before delete.

I have a script that archive files then delete.How do Its working fine,however,before I perform the delete operation,I want to verify that indeed the FILE is in the path of folder I want to archive. For example,I have a path /A/B I want all files in B to be archived,the scripts lists all the... (5 Replies)
Discussion started by: kayarsenal
5 Replies
Login or Register to Ask a Question