event or file wait scenario


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting event or file wait scenario
# 1  
Old 02-09-2009
event or file wait scenario

i want to do 2 things

1) i should wait for a file called A.txt to fall on a specific path on the server
2) once the file arrives immediately another script called B.sh should be executed.

Could you please throw somelight on this.
Any code if already present that would be helpful.

Regards
Rajesh
# 2  
Old 02-09-2009
How large is A.txt? It can "appear" on the host before all of the data has been written. If you "immediately" run another script, you risk affecting a change to a partial file...
# 3  
Old 02-09-2009
hi

hi

A.txt is just an indicator /dummy file... am waiting for this file just to make sure that this is the time ... that i should run b.sh script
# 4  
Old 02-09-2009
One way is to sit in a sleep loop.

Code:
while true
do
        if [ -f A.txt ]
        then
                sleep 10
        else
                break
        fi
done
b.sh


avronius is right. Unless the file is a simple flag created with something like "touch" it could be not ready for processing.
# 5  
Old 02-09-2009
This link might help you a bit:
https://www.unix.com/shell-programmin...#post302272463

Have the script check for the existence of the file that you are referring to - if it finds the file, do stuff...

- Avron
# 6  
Old 02-09-2009
event wait throu unix

hi

thanks for your response.. i have gone through your link but i would like to explain my case once again

I have a script called B.sh
Its not scheduled to run at any specific time.

Now..

I receive a file A.dat at a specified location daily.

Once i see the file ... i should remove it and then B.sh should start

This should happen daily .
# 7  
Old 02-09-2009
Yes the file is a touch file
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Look for a file,if not found wait and look again

Hi All, i have a requirement I created a file list as below : more abc_file_list.txt Rem_DD.csv Rem_Non.csv Rem_Ld.csv CC_Ld_Non_IRA.csv ... Above are the 4 files (For now ,we dont know how many in the file) which need to be present else need to get an email for missing files. ... (3 Replies)
Discussion started by: dssyadav
3 Replies

2. Shell Programming and Scripting

calling a shell script in background and wait using "wait" in while loop

Hi, I am facing a strange issue, when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed. cat abc.txt | while read -u4 line do #if line contains #... (2 Replies)
Discussion started by: mihirvora16
2 Replies

3. Shell Programming and Scripting

Script to wait until file is updated

Hello, I need to evaluate (under BASH) if the certain file has been updated or not. If the file still wasn't updated, script should wait. The script picks up the time stamp of the file using command OldTimestamp=$(date -r $MyDir/$MyFile), but I don't know how to code a waiting loop with new and... (6 Replies)
Discussion started by: sameucho
6 Replies

4. Shell Programming and Scripting

file sending scenario

hi all i have a view in the database with columns prod_no,prod_nm, prod_code using a shell script i should query this view and dump the data in a delimited flat file and send to another ftp server.... i also have to schedule this periodically using cron tab. can you... (2 Replies)
Discussion started by: rajesh_tns
2 Replies

5. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

6. Shell Programming and Scripting

Need to execute 2 scripts, wait, execute 2 more wait, till end of file

:cool: I need to execute a shell script to do the following: cat a file run two back ground processes using the first two values from the file wait till those background processes finish run two more background processes using the next two values from the file wait till those background... (1 Reply)
Discussion started by: halo98
1 Replies

7. UNIX for Dummies Questions & Answers

How to find the File Age and wait for that...

Hi, I want to know my file is 1 hr 30 min old or not, If 1 hr 30 min old I will do some tasks in that file.. other wise I will wait to 1 hr 30 min and then do the tasks.. how to do it in Unix script? any idea? (3 Replies)
Discussion started by: redlotus72
3 Replies

8. Shell Programming and Scripting

Lock a file. AND Wait if file is locked

Hi, I want to do the foll steps: 1. Check if someone has a lock on my file1. 2. if file1 is locked by any other user wait in a loop till another user releases lock 3. when lock released, lock file1. 4. do procesing (write) on file1. 5. processing complete. release lock on file1. ... (2 Replies)
Discussion started by: sunil_neha
2 Replies
Login or Register to Ask a Question