Lan Barnes wrote:
On Thu, September 20, 2007 3:35 pm, Carl Lowenstein wrote:
On 9/20/07, Brad Beyenhof <[EMAIL PROTECTED]> wrote:
Is there any way to trigger a script just by placing a document into a
folder? i.e. Can I print to a file and, by virtue of saving it into a
certain "watched" directory, have the new file's path passed as an
argument to a script?
Probably so. This question comes up occasionally in the news group
comp.lang.postscript. You might try searching the archives on
google/groups. Not sure offhand what the proper search terms would
be.
Actually, I've scripted stuff to do exactly this, and if I can do it, it's
trivial indeed. I wrote a little daemon script that did:
while TRUE {
sleep $aTime
if {(present && !processed) file} {
process
mark processed
}
}
Thing is, scripts can't run as root, so you have to start it as a user.
(Hmm ... do I have to _say_ this is pseudocode? Naw, they're not _that_
dumb.)
There is a better way to do this. For quite a while there has been a
kernel function called inotify, which registers file change
notifications. Documentation is in the kernel source. There is a C
library and programs available at
<http://inotify-tools.sourceforge.net/> that uses the inotify call. You
can get pre-made programs for Fedora through the Extras repository (Main
repository for 7 and later) by doing:
# yum install inotify-tools
See the web page for other Linux versions like Debian.
Gus
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-newbie