Sendig a file and a confirm file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sendig a file and a confirm file
# 1  
Old 04-30-2013
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 of the file?

I was thinking of sending the file via scp/ssh and then once the main file has been sent, send another flag file to confirm that the first file has been completely received.

Is there a better way of doing this, as i am thinking that there could be a problem in transferring of the flag file, so the first main file would have transferred, but the flag file would not have, and therefore the file would not be processed.

Any ideas?

Thanks
# 2  
Old 04-30-2013
I would suggest write a script on destination server which will just touch a <<filename>>.done file and invoke it from source system once main file transmission is done. This will ensure file has arrived successfully on destination folder and if it fails in between .done job wont get executed.
# 3  
Old 04-30-2013
Quote:
Originally Posted by vidyadhar85
I would suggest write a script on destination server which will just touch a <<filename>>.done file and invoke it from source system once main file transmission is done. This will ensure file has arrived successfully on destination folder and if it fails in between .done job wont get executed.
That is one approach, but if there was an incomplete transfer of the file i.e. if the contents were not complete, then the .done file would still be created which would be a problem. Or when using scp is there no chance of an incomplete transfer?
# 4  
Old 04-30-2013
If files are critical then one cant trust scp or ssh. You have to go for tools like Connect Direct etc.
SCP do return $? more than 0 when there is a failuer in copy action.
# 5  
Old 04-30-2013
brunlea,
You don't mention how or when the file is processed on the receiving server. Does the file get processed as soon as it is transferred (i.e. via some file watcher) or does a script run at a certain time to process it? I have used Cyberfusion and Connect Direct to transfer files and they reliably tell you when there is a transfer failure or file is incomplete. Don't have much experience with scp/ssh capturing all errors (I'm sure someone else can weigh in on this), however, something you could do is compare chksum's but this would need to run after file has been transferred (again, that depends on my question on how/when it's processed).

Yet another option is to put a trailer record at the end of the file you are transferring that contains the total number of records on the file. Then the script on the destination server could validate that the total number of records on the file matches the total on the trailer record before processing it.
# 6  
Old 04-30-2013
The file gets processed as soon as it is received, this is why i need to ensure that the full file has been received. The file processer can check first for a flag file etc.

No other tools are available to be installed so scp/ssh is the only option available for me.
The trailer option may be viable. Never done that before, how does that work?
# 7  
Old 04-30-2013
Below is just one example of how you can define a trailer record at the end of the file. The trailer record has a record type (1st char of rec) of '3' and is followed by the total count (000004) of detail records (those with a record type of '2' in this example). The process that reads this file after it's transferred should count the number of actual detail records on the file and compare that number to the total count on the trailer record. If the count is different or if no trailer record is found, then that means that the transfer or file is incomplete. This file also contains a header record with a date which the process can also validate so an older or unexpected file is not processed. Surely there can be many variations to this.
Code:
 
cat file.txt
1 20130430
2 Detail Rec 1
2 Detail Rec 2
2 Detail Rec 3
2 Detail Rec etc
3 000004

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to confirm that I've reached the nproc limit?

Hi, I am getting the error su: cannot set user id: Resource temporarily unavailable. In limits.conf, it shows soft nproc 2047 for this user. ps H -u | wc -l shows 508 processes only. Linux flavour is Red Hat Enterprise Linux Server release 5.10 (Tikanga) Any advice will be much... (1 Reply)
Discussion started by: newbie_01
1 Replies

2. 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

3. 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

4. Shell Programming and Scripting

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... (4 Replies)
Discussion started by: palanisvr
4 Replies

5. 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

6. 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

7. Solaris

Confirm the location of the bootblk kernel

Dear All i am new to solaris. I am using solaris 5.10 running on my sun blade 150 (sparc). Nowadays i studying about boot process and i am bit confused with the location of the kernel,bootblk. As i found through the internet, The location of the kernel is ... (0 Replies)
Discussion started by: kingston
0 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