Sponsored Content
Full Discussion: Generic Filewatcher
Top Forums Shell Programming and Scripting Generic Filewatcher Post 302776761 by Chubler_XL on Wednesday 6th of March 2013 08:52:48 PM
Old 03-06-2013
You could try something like this, not they after finding a watch file you should probably delete or move it aside to stop actions repeating on every check:

Code:
function load_conf
{
  POS=0
  while read line
  do
     S[POS]="$line"
     let POS=POS+1
  done < $1
}

while read WATCH CONF
do
    POS=${#WF[@]}
    WF[POS]=$WATCH
    CF[POS]=$CONF
done < master

for((i=0;i<${#WF[@]};i++)) {
    if [ -f "${WF[i]}" ]
    then
        load_conf ${CF[i]}
        for((j=0;j<${#S[@]};j++)) {
            echo "${S[j]}" | while read -a run
            do
                for((k=0;k<${#run[@]};k++)) {
                    eval ${run[k]} \> $(basename ${run[k]}).out "2>" $(basename ${run[k]}).stderr &
                }
                wait
            done
        }
    fi
}

This User Gave Thanks to Chubler_XL For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

GENERIC Kernel

How do I update, change, reconfigure or whatever it is that I have to do, in order to rid the GENERIC label. It just means that it is the basic kernel shipped with the OS right? Im using FBSD 4.5 (2 Replies)
Discussion started by: savage
2 Replies

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

3. Shell Programming and Scripting

generic way - help required

All, This is what I did: Suppose: $ line="23|12|21" $ eval $(echo "$line" | awk -F'|' '{print "V1="$1";V2="$2";V3="$3}') $ echo $V1 23 $ echo $V2 12 $ echo $V3 21 (3 Replies)
Discussion started by: uwork72
3 Replies

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

5. UNIX for Advanced & Expert Users

Is aclocal.m4 generic?

can we copy higher version aclocal to our software. Is there any good book for automake,aclocal.m4,configure.sub,configure.guess that explains clearly about how they are related , how to modify them etc Thanks Gopi (1 Reply)
Discussion started by: Gopi Krishna P
1 Replies

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

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

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
Config::Watch(3)					User Contributed Perl Documentation					  Config::Watch(3)

NAME
Log::Log4perl::Config::Watch - Detect file changes SYNOPSIS
use Log::Log4perl::Config::Watch; my $watcher = Log::Log4perl::Config::Watch->new( file => "/data/my.conf", check_interval => 30, ); while(1) { if($watcher->change_detected()) { print "Change detected! "; } sleep(1); } DESCRIPTION
This module helps detecting changes in files. Although it comes with the "Log::Log4perl" distribution, it can be used independently. The constructor defines the file to be watched and the check interval in seconds. Subsequent calls to "change_detected()" will o return a false value immediately without doing physical file checks if "check_interval" hasn't elapsed. o perform a physical test on the specified file if the number of seconds specified in "check_interval" have elapsed since the last physical check. If the file's modification date has changed since the last physical check, it will return a true value, otherwise a false value is returned. Bottom line: "check_interval" allows you to call the function "change_detected()" as often as you like, without paying the performing a significant performance penalty because file system operations are being performed (however, you pay the price of not knowing about file changes until "check_interval" seconds have elapsed). The module clearly distinguishes system time from file system time. If your (e.g. NFS mounted) file system is off by a constant amount of time compared to the executing computer's clock, it'll just work fine. To disable the resource-saving delay feature, just set "check_interval" to 0 and "change_detected()" will run a physical file test on every call. If you already have the current time available, you can pass it on to "change_detected()" as an optional parameter, like in change_detected($time) which then won't trigger a call to "time()", but use the value provided. SIGNAL MODE Instead of polling time and file changes, "new()" can be instructed to set up a signal handler. If you call the constructor like my $watcher = Log::Log4perl::Config::Watch->new( file => "/data/my.conf", signal => 'HUP' ); then a signal handler will be installed, setting the object's variable "$self->{signal_caught}" to a true value when the signal arrives. Comes with all the problems that signal handlers go along with. TRIGGER CHECKS To trigger a physical file check on the next call to "change_detected()" regardless if "check_interval" has expired or not, call $watcher->force_next_check(); on the watcher object. DETECT MOVED FILES The watcher can also be used to detect files that have moved. It will not only detect if a watched file has disappeared, but also if it has been replaced by a new file in the meantime. my $watcher = Log::Log4perl::Config::Watch->new( file => "/data/my.conf", check_interval => 30, ); while(1) { if($watcher->file_has_moved()) { print "File has moved! "; } sleep(1); } The parameters "check_interval" and "signal" limit the number of physical file system checks, simililarily as with "change_detected()". COPYRIGHT AND LICENSE
Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess <cpan@goess.org>. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.1 2010-02-07 Config::Watch(3)
All times are GMT -4. The time now is 06:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy