Filewatcher job


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Filewatcher job
# 1  
Old 05-17-2012
Filewatcher job

Hi Friends
iam using a filewatcher job which checks the path in intervals
below is the script
Code:
#!/bin/ksh
fileflag=0 
timer1=0 
check_interval=120 # check every 2 minutes 
(( check_interval_minutes=${check_interval}/60 )) 
while [ ${timer1} -lt 180 ] 
do 
if [ -f /home/ab1234/files/abcd.dat ] 
then 
echo "My file exists now..." | mailx -s "File status" emailid
fileflag=1 
exit
else 
sleep ${check_interval} 
fi 
(( timer1=${timer1} ${check_interval_minutes} )) 
done 
#if it does not show up, send alert 
if [ ${fileflag} -eq 0 ] 
then 
echo "1 hours past. FIle still did not arrive" | mailx -s "File status ALERT!" emailid
fi 
# if it passes this point and  watch until file arrives 
while [ ${fileflag} -eq 0 ] 
do 
if [ -f /home/ab1234/files/abcd.dat ] 
then 
fileflag=1 
echo "File arrived and processesing at `date`" | mailx -s "File status" emailid
exit 
else 
sleep ${check_interval} 
fi

and when i run im getting
Code:
ksh: syntax error: `do' unmatched

Machine:AIX

Last edited by Scrutinizer; 05-17-2012 at 06:19 AM.. Reason: code tags
# 2  
Old 05-17-2012
There is a "done" missing. It helps if you indent your code, then you would have noticed it instantly..
# 3  
Old 05-17-2012
Thanks a lot!
added Done at the end
executed the script in this fashion
Code:
. ./script.ksh .

and got the below error
Code:
$ . ./filewatcher.ksh .
ksh:  timer1=0 2 : syntax error

please advise!

Last edited by Scrutinizer; 05-17-2012 at 06:37 AM..
# 4  
Old 05-17-2012
Yes that is a syntax error. I do not know what you are trying to achieve here, I think the arithmetic operator is missing...

That is not how you execute a script BTW. Try:
Code:
./filewatcher.ksh .

Make the script executable first..
# 5  
Old 05-17-2012
Actually the line
check interval is not resolving
Code:
check_interval=120 # check every 5 minutes
(( check_interval_minutes=${check_interval}/60 ))

tried debugging the scrpt using ksh -vx

Last edited by Scrutinizer; 05-17-2012 at 06:47 AM.. Reason: code tags
# 6  
Old 05-17-2012
I think it is. According to your error message, the value is 2.

--
Please view this link to learn the use of code tags.
This User Gave Thanks to Scrutinizer For This Post:
# 7  
Old 05-17-2012
i give up ,
unable to solve
BTW # 5 minutes is a typo error
Getting the same error
Code:
 
+ sleep 120
+ ((  timer1=0 2  ))
filewatcher.ksh[16]:  timer1=0 2 : syntax error

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filewatcher

hi All, I ned to write a filewatcher script, with following requirements. 1. The script should look for the file in every 5 min. 2. If the file is found, it should check in every 3 min the size of file. 3. if the file size has not changed in last 4 iterations (i.e. in last 12 min), the... (2 Replies)
Discussion started by: alok2082
2 Replies

2. Shell Programming and Scripting

Generic Filewatcher

Hi, I have a requirement wherein i need to have a generic file watcher in place. On presence of a file in a particular directory,the file watcher should identify the related config file and execute the series of the shell scripts mentioned in the config file. eg.Config file a.sh b.sh... (7 Replies)
Discussion started by: dikesm
7 Replies

3. Shell Programming and Scripting

Autosys filewatcher + ksh script

Hi, A ------> B ------> C I have a scenario where each day, my server B would ftp to server A and pull (A,B,C,D,E) from a specific directory. Server C would need files (B,D) only when server B finished receiving from server A. These files change everyday, so sometimes it takes longer... (3 Replies)
Discussion started by: arex876
3 Replies

4. Shell Programming and Scripting

autosys job configuration for job failure.

We need to configure autosys that when a job fails continously for 3 times, we need to call another job. Is this possible in Autosys, or can anyone advice on the alternative. (2 Replies)
Discussion started by: sangea
2 Replies

5. Shell Programming and Scripting

Script to Start a Job after finding the Old job completed

Hi Experts, I need a script advice to schedule 12 jobs ( SAS Codes execute back ground ). Algorithem: 1. Script checks first job. 2. Finds first job is done; invoke second job. 3. finds second job is done; invoke third job. .. Request you to please assist. (3 Replies)
Discussion started by: Jerald Nathan
3 Replies

6. Shell Programming and Scripting

FileWatcher Script

Hi All, Sorry to post these many questions on UNIX. i am new to unix & got only UNIX work in my organization. I need to make a script for File Arrival Check. 1. The script should wait for indicator file for configured amount of time. 2. If the file is not received after the configured... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies

7. UNIX for Dummies Questions & Answers

How to insert child job under a box job?

I have this box job and it contains only one job under it which is to load a file. I want to insert a "File Watcher", "Copy File" to it? Have no clue how to do that...any help plzzz... (4 Replies)
Discussion started by: xejatt
4 Replies

8. Shell Programming and Scripting

Problem with filewatcher...

Hi everyone, Please find the script for Filewatcher rule file,which does the simple job of moving the files whenever it dectects to another directory.And whenever it detects the cmd_mm.stop file,it should terminate the job. INTERVAL 60 ON_FILEWATCH ${HLD}/CMD/* CREATE 0 1 2 0400 5 THEN... (2 Replies)
Discussion started by: bhagat.singh-j
2 Replies

9. Solaris

killing a unix job after the job process gets completed

Hi, Thanks in advance. i need to kill a unix background running job after that job process completes. i can kill a job by giving the following unix command kill -9 processid how to kill the job after the current process run gets completed ? Appreciate your valuable help. Thanks... (7 Replies)
Discussion started by: dtazv
7 Replies

10. Shell Programming and Scripting

killing unix job after the job process completes

Hi, Thanks in advance. i need to kill a unix background running job after that job process completes. i can kill a job by giving the following unix command kill -9 processid how to kill the job after the current process run gets completed ? Appreciate your valuable help. ... (1 Reply)
Discussion started by: dtazv
1 Replies
Login or Register to Ask a Question