event or file wait scenario


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting event or file wait scenario
# 8  
Old 02-09-2009
Does the file you are using as a kind of semaphore original on the same server as the script you are running, or does it originate on a different server?
# 9  
Old 02-09-2009
Minor revision to methyl's script
Code:
while true
do
        if [ -f A.txt ]
        then
           # If the file exists, run b.sh
           b.sh
           exit 0
        else
           # If the file does not exist wait a small increment of time
           sleep 10
        fi
done

# 10  
Old 02-09-2009
My source system sends a dummy file on to my server on a specified path.
My work is to .. wait for the file
delete it once i find it
and start b.sh script.

am deleting the file so that i should again wait for the file to arrive tomorrow from source
# 11  
Old 02-09-2009
H avronius

i think we are getting close.. but my doubt is

say we did not get the file it goes executes sleep10 .. wat next after 10 seconds?

and should i write this< if code i>n another a.dat file and schedule it using cron to run continously ?
# 12  
Old 02-09-2009
Why don't you test it and see what happens?

I tested by running the script without A.txt
I waited about 15 seconds - of course, nothing happened
I put the command to sleep, I touched A.txt
I brought the command back to the foreground
It immediately discovered that A.txt was there - and reported that the condition was met.

In it's current state, it will run once - and keep waiting for the file to appear. Once the file appears, it will do whatever is in the "then" part of the loop. It will then stop running.
# 13  
Old 02-09-2009
Quote:
Originally Posted by rajesh_tns
My source system sends a dummy file on to my server on a specified path.
My work is to .. wait for the file
delete it once i find it
and start b.sh script.

am deleting the file so that i should again wait for the file to arrive tomorrow from source
Instead of using a file as a signal, why not use a signal and have one file send a signal to the other file?

For example, see this site search result:

https://www.unix.com/cfmgoogle.php?cx...sa=Search#1077

Last edited by Neo; 02-09-2009 at 05:18 PM.. Reason: added serach link
# 14  
Old 02-09-2009
Hi all with your help I think we got the solution

1. Create a file First.dat with the following code mentioned by avronius and methyl's

while true
do
if [ -f A.txt ] -- checks if A.txt file arrived or not
then
# If the file exists, delete A.txt and run b.sh
rm A.txt
b.sh
exit 0
else
# If the file does not exist wait a small increment of time
sleep 10
fi
done

2. Schedule First.dat to run for every minute

Actions:

Once it finds A.dat then If condition is satisfied and b.sh will run and program breaks.

and it waits for the file for tomorrow again .. the same way

sincere Thanks for all of you ..
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