# FileWatcher Script

**URL:** <https://community.unix.com/t/filewatcher-script/217488>\
**Category:** Shell Programming and Scripting\
**Created:** [October 22, 2008, 1:28am UTC](https://community.unix.com/t/filewatcher-script/217488 "2008-10-22T01:28:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit.Sagpariya](https://community.unix.com/letter_avatar/amit.sagpariya/32/6_449c533f586939b6e5f246632a46421f.png) [@Amit.Sagpariya](https://community.unix.com/u/Amit.Sagpariya)\
**Post date:** [October 22, 2008, 1:28am UTC](https://community.unix.com/t/filewatcher-script/217488/1 "2008-10-22T01:28:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Amit.Sagpariya](https://community.unix.com/letter_avatar/amit.sagpariya/32/6_449c533f586939b6e5f246632a46421f.png) [@Amit.Sagpariya](https://community.unix.com/u/Amit.Sagpariya)\
**Post date:** [October 22, 2008, 10:57am UTC](https://community.unix.com/t/filewatcher-script/217488/2 "2008-10-22T10:57:47Z")

</div>

Hi all,

Can someone help me on this requirement.. i really appreciate for this....

---

<div class="post-metadata">

**Author:** ![DukeNuke2](https://community.unix.com/user_avatar/community.unix.com/dukenuke2/32/407_2.png) [@DukeNuke2](https://community.unix.com/u/DukeNuke2)\
**Post date:** [October 22, 2008, 12:11pm UTC](https://community.unix.com/t/filewatcher-script/217488/3 "2008-10-22T12:11:27Z")

</div>

please don't "bump" up your posts, it's against the rules of [unix.com](http://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

---

<div class="post-metadata">

**Author:** ![Amit.Sagpariya](https://community.unix.com/letter_avatar/amit.sagpariya/32/6_449c533f586939b6e5f246632a46421f.png) [@Amit.Sagpariya](https://community.unix.com/u/Amit.Sagpariya)\
**Post date:** [October 23, 2008, 12:19am UTC](https://community.unix.com/t/filewatcher-script/217488/4 "2008-10-23T00:19:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Amit.Sagpariya](https://community.unix.com/letter_avatar/amit.sagpariya/32/6_449c533f586939b6e5f246632a46421f.png) [@Amit.Sagpariya](https://community.unix.com/u/Amit.Sagpariya)\
**Post date:** [October 27, 2008, 6:04am UTC](https://community.unix.com/t/filewatcher-script/217488/5 "2008-10-27T06:04:58Z")

</div>

Hi All,

I made the solution for this...

```nohighlight
#!/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

```
