[NTLUG:Discuss] Setting up a watch folder

Ben Weatherall bweatherall at pdxinc.com
Thu Jan 15 10:18:56 CST 2009


Regardless of which scripting language you use, if you are going to
trigger at 1-minute intervals you are probably going to have to use some
form of semaphore locking (probably file based) so that a newer
instantiation of the script will not try to send the same file already
being processed by an older instantiation.

-Ben Weatherall

-----Original Message-----
From: discuss-bounces at ntlug.org [mailto:discuss-bounces at ntlug.org] On
Behalf Of Daniel Hauck
Sent: Wednesday, January 14, 2009 3:53 PM
To: NTLUG Discussion List
Subject: [NTLUG:Discuss] Setting up a watch folder

This is definitely something I could cobble together on my own but I
have decided to pose the question here because the answers might be more
generally educational and because the answers might be better than
anything I would have considered.

Here's the project:

Users on a small network (3 users total) are using an SME server to host
their files, their logins and that sort of thing.  They also print
through this server.  They have an HP600 plotter at their site as well.

Recently, for whatever reason, their ability to send plot files to their
plotter has broken.  Probably some Windows update has thrown a
monkey-wrench into the works, but I don't care to fix Windows problems
and it occurred to me that all we need to do is set up a watch folder
and let people drag and drop their plot files into the folder and let
the server do the job of queuing the file and spooling to the plotter.

I have already successfully sent a plot file to the plotter from command
line, so that functionality is simple and works.  So now I just want to
set up a "watch folder" that will respond to plot files being present by
sending them to the plotter and then deleting the file.

I imagine setting up a cron job to run every minute and when it sees a
file in the folder, it would launch a script that does the work.

How would "you" do it?  I like bash scripting, but perl would be fine...
or frankly, whatever you like best.

This is the sort of process that could be adapted for all sorts of tasks
such as image processing or anything else you would like to let a server
handle in response to a file being copied to a folder.

_______________________________________________
http://www.ntlug.org/mailman/listinfo/discuss



More information about the Discuss mailing list