SUMMARY - trap on input to a file

From: Stuart Whitby (swhitby@legato.com)
Date: Thu Aug 10 2000 - 06:28:03 CDT


Apologies for the resend - this time with original question at the
bottom by popular request.

Thanks to:

Thomas Knox
Craig McLean
Sanjiv K. Bhatia
Denise Naomi Ishikawa
Bruce R. Zimmer
Ravi Channavajhala

for their answers. Ideas included using fstat() in C to continually
check the file, sending output to stderr (no can do - it's built
into the binary and I'd still need to set a constant watch),
modifying the program that's generating the message (no can do -
don't have access to them). But the winners, for us scripting guys,
are:

swatch, which is freely available and already set up to do this
stuff, and changing the output file to a named pipe (mknod <file> p).
Using the named pipe is the method I've gone for, mostly because I
received that response first (it also saves me time learning how to
configure swatch - another bonus). I can now read from that pipe and
act on the input as it is received.

One possible problem with this approach though, as highlighted by
Bruce Zimmer - if the pipe fills up, the application writing to it
may hang.

Original question:

I'm trying to get something set up to react to a specific message
which goes to a logfile, and could do with some advice on the best
way to do this.

There are a number of programs which append messages onto one file.
I'd like to run a command when one of those messages occurs. Thing
is, I want to run it *instantly*, and tail -f works in 1 second
intervals. I originally thought I could create a shell script with
the same name as the file, then figured out that was silly, since
all that'll happen is messages will be appended to the logfile.
I'm fairly decent at shell scripting, but don't know C or Perl,
which may help me do what I'm trying here.

If anyone has any suggestions, I'd appreciate them.

TIA,

Stuart Whitby.

S
U BEFORE POSTING please READ the FAQ located at
N ftp://ftp.cs.toronto.edu/pub/jdd/sun-managers/faq
. and the list POLICY statement located at
M ftp://ftp.cs.toronto.edu/pub/jdd/sun-managers/policy
A To submit questions/summaries to this list send your email message to:
N sun-managers@ececs.uc.edu
A To unsubscribe from this list please send an email message to:
G majordomo@sunmanagers.ececs.uc.edu
E and in the BODY type:
R unsubscribe sun-managers
S Or
. unsubscribe sun-managers original@subscription.address
L To view an archive of this list please visit:
I http://www.latech.edu/sunman.html
S
T



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:14:14 CDT