FileWatcher Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FileWatcher Script
# 1  
Old 10-22-2008
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 amount of time, it should check the table in oracle which has a filed "Next Feed Date". If a feed is not expected, then it should create necessary touch file & then exit from the process.
3. If the feed is expected & still not received raise a FATAl error & continue to wait for the file.
4. Once the feed is detected, wait until the file is transfer & then do feed validation (Feed validation script i have completed).


Could someone help me if this kind of script is handy...
# 2  
Old 10-22-2008
Hi all,

Can someone help me on this requirement.. i really appreciate for this....
# 3  
Old 10-22-2008
please don't "bump" up your posts, it's against the rules of unix.com!

also i think nobody is going to write a script for you. it's your work to write this script. just start it and see how far you can get and if you stumble upon a problem... you will find help. but YOU have to start the script!

thanks,
DN2
# 4  
Old 10-23-2008
Hi DukeNuke,

I was not asking to write a script for me. I have asked to pass if someone has handy. Else couple of comand or hints which i can use for this requirement is enough

Main problem is i do not know unix much & even i do not know if there is any functionality exists in unix which we can use to make filewatcher script.

Thanks for your understanding.

Regards,
AS
# 5  
Old 10-27-2008
Hi All,

I made the solution for this...

Code:
#!/bin/sh


datafile=$1
indfile=$2

waittime=100
starttime=0
while [ $starttime -le $waittime ]
do
	if [ -f $indfile ]
	then
		do your process (ie run feed validation script)
		exit 0
		
	else
		sleep 10;
		starttime=`echo "$starttime + 10" | bc`
			
		if [ $starttime -eq $waittime ]
		then
			echo "Waittime excceded"
			Get_feed_date=`sqlplus -s amit/amit@amit  <<END 
			set feedback off;
			set heading off;
			select to_char(fdnxtdt, 'YYYYMMDD') from amit where  source_desc='$1';
			exit;
			END`
			
			if [ $Get_feed_date -ne $timestamp ]
				then
					touch xxx.wit
					exit 0
				else
					echo "File has not arrived yet; continue to wait !!"
					starttime=0
				fi
		fi
	fi
done


Last edited by DukeNuke2; 10-27-2008 at 08:48 AM.. Reason: added code tags for better reading
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 block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. 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

4. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

5. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

6. 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

7. UNIX for Dummies Questions & Answers

Filewatcher job

Hi Friends iam using a filewatcher job which checks the path in intervals below is the script #!/bin/ksh fileflag=0 timer1=0 check_interval=120 # check every 2 minutes (( check_interval_minutes=${check_interval}/60 )) while do if then echo "My file exists now..." | mailx -s... (7 Replies)
Discussion started by: robertbrown624
7 Replies

8. 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

9. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

10. 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
Login or Register to Ask a Question