RSS Feed

RSS

Comments RSS

The Watch Folder

For the programmers and systems administrators among us.  Consider the following, and all too common, programming task. Events from one process need to trigger actions by another.  Now, the impulse may be to try to impliment a direct method of communications between the two process via networking sockets, low level OS signals, etc.  While this may be good to consider or even use at times, there may be a far more simple and less problematic method that is almost always worth considering – the Watch Folder.    If both processes can have access to a common directory, via network share or direct filesystem mount for instance, then all one has to do is have the first process drop a small file to the locaton and have the other process be watching for it, act in response and then clear it out and wait again for the next time the file appears in order to act again.   The second process can watch for it directly or have some other task be the watcher that then calls the final process, perhaps through a periodic call from a task scheduler such a cron.   There are lots of realitively simple ways of implementing such an arrangement without resorting to more complex networking or OS signaling programming schemes.   The Watch Folder methodology works well in any language but is particularly easy to implement in simple scripting languages that are available as part of the command shell of most any OS, such as BASH in Linux, Bourne or Korn Shell in Unix, or DOS Batch or Powershell script in Windows.

ASCII Mandelbrot Fractal – as a Python CGI

Here is an example of a Python CGI that I have running on my SDF.org website.  It generates a ASCII Mandelbrot Fractal and allows for the user to change and zoom in the field of view.  Granted, it is very low resolution being ASCII, but the main purpose was to demonstrate the use of Python for CGI purposes on SDF.org.   (FOR FURTHER EXPLORATION):   Since the SDF.org server Python package (v 2.6.5) has the PIL (Python Image Library) available, I can see no reason that true binary images of Mandelbrot fractals might not be produced and displayed on as pictures on the web page.  UPDATE:  As suspected, creating true graphical Mandelbrot fractals did in fact work out well.   Here is a link to a Python CGI that uses PIL to create the images.  Graphical Mandelbrot CGI