waiting for the files untill they loads


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting waiting for the files untill they loads
# 1  
Old 05-20-2011
MySQL waiting for the files untill they loads

Hi guys,

I want to know how to wait for the files untill they are loaded through ftp

here the scenario is

i'm searching for the files in unix directory
/stage_area/loadfiles/telsims/test/
and there are 39 files daily i will recieve with names like *.todays_date

i.e filename.20110520

i have a script to search whether these 39 files are avaliable or not.
And my question is i have to wait untill all the 39 files are loaded in to that folder and there will no transfer of data in to that files.

how can i do this..
# 2  
Old 05-20-2011
It would be best if your sender could include a flag to say that they were all delivered, i.e. create a zero or one byte file called *.todays_date.complete

That way you would have the confidence that the inbound ftp had completed without error (assuming that the sender does not send the 'complete' file as a separate transfer without checking for errors) which is better than just using fuser to check if the file is open.

If you know you need 39 files and they all come from different transfers, you may have to just script up something like this:-
Code:
#!/bin/ksh
cd /stage_area/loadfiles/telsims/test

todays_date=`date +%Y_%m_%d`   # Assuming that this is the format you want
until [ `ls -1 *.${todays_date}.complete | wc -l` -eq 39 ]
do
     sleep 10
done

echo "All files arrived.  Continuing with main processing."



Does that help?



Robin
Liverpool/Blackburn
UK
# 3  
Old 05-20-2011
I'm sure you meant:
Code:
ls -1 *.${todays_date} | wc -l

I'd add extra 'sleep's, in case the files are large or the transfer is slow.
# 4  
Old 05-20-2011
I was using the 'complete' file I described so you can be sure that the sender has completed the transfer, that's all.

The code will just loop until the criteria are met.


I hope it helps.




Robin
# 5  
Old 05-20-2011
In case there are no files:
Code:
ls -1 *.${todays_date} 2>/dev/null | wc -l

# 6  
Old 05-23-2011
Hi Robin,

Thanks for your reply...

the above script is ok but it will just says when 39 files are avaliable.

My question is if the file is still on process how to idetify it and wait untill it loads..

'FUSER ' it will shows which files are open..
i tried using LSOF, but ididn't get it...

can u give me an suggestion..

Once again thanks for all for giving me reply...

regards,
venkat..
# 7  
Old 05-23-2011
The best way to avoid is , use a temporary extension (f.tmp)while ftping a file. once compeleted the ftp script can rename the file from f.tmp to f.

This is a fail proof method. And you also use fuser to check still any files are opened by the ftp user.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to iterate a function untill last argument with any order of input?

HI I need to get the function "kick" to get executed in any way the parameters are passed in to the function. The parameters are first stored in a dictionary self.otherlist = {} print self.otherlist self.populateTestList(self.system_type) print... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies

2. AIX

Su loads .profile with argument

Hello, Is there any way to su another user and loading its profile with an argument. For example I am user1 and I want to start user2 user2 .profile is interactive asking user to pass some values I want to automate a process by switching user and if I pass an argument the interactive... (4 Replies)
Discussion started by: geodimo
4 Replies

3. Shell Programming and Scripting

Bash script parallel tasks and command to wait untill complete?

Hello, im having bash script with while *** command1 && command2 && command3 && done i want to ask how i can prevent overloading server, by waiting untill all commands complete? any low resources intensive command like "wait" - i dont know if exist? (2 Replies)
Discussion started by: postcd
2 Replies

4. UNIX for Dummies Questions & Answers

launchctl loads app with icon (OS X)

We are deploying an app to our students that is running as a daemon. It keeps them from using certain software. The problem is that when we initially deploy it we don't want to require a restart. So we decided to use launchctl to load the daemon manually. When we do it this way, though, the... (4 Replies)
Discussion started by: nextyoyoma
4 Replies

5. Programming

Python pickle.loads(string)

Will this sentence return the decode of the string? Why I put a string in it but the system say: invaild load key (1 Reply)
Discussion started by: Henryyy
1 Replies

6. Debian

Can't see anything after debian loads

Hey, I recently installed Debian on a desktop PC but when it starts I can't see anything (the monitor say no signal). I don't have any idea or even a way to figure out what going on here since I can't see anything at all not even the console. Is there something that I missed in the install, or is... (22 Replies)
Discussion started by: neur0n
22 Replies

7. UNIX for Advanced & Expert Users

How OS loads process in memory to execute ?

Hi, I was Googling to get info "How OS loads process into its memory to execute?" i mean when i execute ./<exename> , How OS exectes it? It will be better if i tell my intention, In my $LOGNAME saveral process are running, among all of these two process are my target process. Basically I... (1 Reply)
Discussion started by: ashokd001
1 Replies

8. UNIX for Dummies Questions & Answers

Adding loads of columns

Hi All, I've got file1 like this: aaa bbb ccc ddd eee fff ggg hhh kkk ppp mmm nnn and file 2 like this: aaa qqq www ddd fff ggg ggg sss zzz ppp vvv yyy and file 3 like this: aaa ggg ppp I need to match the first column of file3 and file1, then add the rest of the file 1 to... (3 Replies)
Discussion started by: zajtat
3 Replies

9. Linux

Details about the way 'gcc' compiles,links and loads?

Hi all, Can any body provide me with a link that gives the core details of the three processes(given below) in concern with 'gcc'? 1)Compiling 2)Linking 3)Loading (1 Reply)
Discussion started by: me_himanshu
1 Replies

10. UNIX for Dummies Questions & Answers

SCO CPU Loads

I've been asked to get a breakdown of what is consuming CPU time on our server over an extended period ? Have been asked about the CPU load on our server and I need to be able to go back to my boss and indicate what % is consumed by what process (or group of processes). I.e. 15% is database... (2 Replies)
Discussion started by: Cameron
2 Replies
Login or Register to Ask a Question