File Processing after complete transfer


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File Processing after complete transfer
# 1  
Old 03-02-2007
File Processing after complete transfer

Hello everybody

I have wriiten a script that, processes a file, only after its found in a particular folder, the files come in via ftp, everyday at different times, morning, afternoon and evening. The script is run every 5 minutes(0,5,10,15,20...55 minutes) of every hour.

The problem i am facing is these files are quite big, and sometimes, these files come in a few seconds before the script is invoked, by that time, the file transfer is still in progress, but since the script has found the file, it runs the rest of the script on it, without making sure that the file transfer is complete.
resulting in the failure of the job.
I am very new to unix, and I was wondering if theres a way to make sure that the file transfer is complete, or a way to make the script wait until the original file is transferred in full.

Thanks,
# 2  
Old 03-02-2007
use "rsync" for incremental backup and transfer, this should reduce the number of attempts for transferring this file, or, in order to make sure that the files are transferred, put a sleep 100 or 200 secs and give them some time before proceeding with the rest of the code.
# 3  
Old 03-02-2007
Interesting ! Smilie


File which is in progress can be identified through lsof command,

which would list files opened and the associated process that had opened it.

Consider this example,

#include <stdio.h>

Code:
int main()
{
        while(1)
        {
          fprintf(stdout, "dummy\n");
        }
return 0;
}


When this run as,

Code:
./a.out > dummy

Would be displayed with lsof as,

Code:
lsof dummy
COMMAND   PID    USER   FD   TYPE DEVICE      SIZE    NODE NAME
<Information below>

Since the script is well aware of which it is going to process,
lsof can be done on that script!

Smilie
# 4  
Old 03-02-2007
When using FTP transfer the file with a "wrong" name. When the transfer is done you rename the file to it's correct name in the same FTP session.
# 5  
Old 03-02-2007
Thanks

Thank yourl, for the excellent suggestions, now i have 4 great solutions to work around with.
# 6  
Old 03-02-2007
Quote:
Originally Posted by sb008
When using FTP transfer the file with a "wrong" name. When the transfer is done you rename the file to it's correct name in the same FTP session.
smart suggestion Smilie
# 7  
Old 03-02-2007
Quote:
Originally Posted by karimone
Thank yourl, for the excellent suggestions, now i have 4 great solutions to work around with.
In my previous project we used to use "lsof" to detect the same thing - as suggested by matrix above.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

2. Shell Programming and Scripting

Unix Scripting : Sort a Portion of a File and not the complete file

Need to sort a portion of a file in a Alphabetical Order. Example : The user adam is not sorted and the user should get sorted. I don't want the complete file to get sorted. Currently All_users.txt contains the following lines. ############## # ARS USERS ############## mike, Mike... (6 Replies)
Discussion started by: evrurs
6 Replies

3. UNIX for Dummies Questions & Answers

SFTP transfer does not complete

I am able to connect to a site and start a file transfer via SFTP, but when the file reaches "100%" -- the file does not complete and "stop". The 100% transfer status does not change (obviously), but the timer for SFTP keeps going and will not complete. This also happens when I try to get a file.... (2 Replies)
Discussion started by: loganban
2 Replies

4. Shell Programming and Scripting

Insert a complete file into another file after certain fixed line

Hi Friends, I am writing a shell script where it is required to insert a file say file1 into file2 after certain number of fixed lines in file2.. Please help me how this could be done.. Please suggest me any useful links i need to go through to achieve this.... Thanks in advance .. (2 Replies)
Discussion started by: amr89
2 Replies

5. Shell Programming and Scripting

How to find complete file names in UNIX if i know only extention of file

Suppose I have a file which contains other file names with some extention . text file containt gdsds sd8ef g/f/temp_temp.sum yyeta t/unix.sum ghfp hrwer h/y/test.text.dat if then.... I want to get the complete file names, like for above file I should get output as temp_temp.sum... (4 Replies)
Discussion started by: panchal
4 Replies

6. Solaris

How to understand if a file is complete

Hi there, files are being transferred via ftp to a folder in my machine which runs solaris 8. I would like to know if is possible to find out from my side if a file is completely transferred or not. Is there a way to control this? Thanks! (6 Replies)
Discussion started by: sickboy
6 Replies

7. Shell Programming and Scripting

grep "226 Transfer complete" | wc -l

echo $ftp_ctr returns '0' instead of '1'. Please help 331 Enter password 230 User logged in 200 Transfer mode set to BINARY local: file1 remote: file2 227 Entering Passive Mode (xxxxxxxx). 125 Uploading in BINARY file xxx 226 Transfer completed 24453780 bytes sent in 67 seconds... (9 Replies)
Discussion started by: Lenora2009
9 Replies

8. Shell Programming and Scripting

How Get Complete Date in List of file

Hi, I am unable to get the complete date format in ls command. I need to list file with complete date format in home directory. If I give 2007/01/01 then i should get all the log files below that particular date. Pls help me (2 Replies)
Discussion started by: Satyak
2 Replies

9. UNIX for Dummies Questions & Answers

BASH complete-filename & menu-complete together

Hi, Does anyone know how to make BASH provide a list of possible completions on the first tab, and then start cycling through the possibilites on the next tab? Right now this is what I have in my .bashrc: bind "set show-all-if-ambiguous on" bind \\C-o:menu-complete This allows... (0 Replies)
Discussion started by: Mithu
0 Replies

10. Shell Programming and Scripting

start job after complete transfer....

Hi, I have a situation... I have a script it checks for a file in a folder which comes to the folder every day at specified time...2am to 4 am, once the file is in the polder my process starts...but the problem is the files being placed are huge and it is even taking half an hour for the file... (3 Replies)
Discussion started by: mgirinath
3 Replies
Login or Register to Ask a Question