CallHelix 2.1.1


Using Folder Actions to Import Data Into Helix

This example is taken from our own library of scripts that run every day. This set takes the WebStar log files from our OS 9 web server (which are rolled every hour) and loads them into our Helix database. We also have a script that rolls our Apache (OS X) log files and moves them to the same folder (on the OS 9 machine) but that isn't found in this package. Sorry. Folder Actions returned to OS X in version 10.3, and are allegedly even better than they were in OS 9, but I haven't had time to work with them yet.

Download the Folder Actions Example

To attach a Folder Action to a folder, just Control-click on the folder, select "Attach a Folder Action" from the contextual menu, and choose the script you want to attach.

Important

The main script requires the 24U Appearance OSAX. You can get a demo version at http://www.24usoftware.com. I find this scripting addition to be incredibly useful and recommend it highly. Unless you are are using AppleScript Studio with OS X, the sort of things it provides are impossible.


About the Pieces

KeepWindowOpen.scr

Folder Actions in OS 9 require that the window remain open, and this script makes sure the window stays open. (It's also a fun and harmless prank to pull on an unsuspecting co-worker. "Why won't this window close!")

WebStarLogProc.scr

Because Folder Actions in OS 9 leak memory, attempting to process these log files directly results in the Folder Action extension running out of memory very quickly. So our script is just a simple 'handoff' script: when it sees a new file has arrived it launches the actual processing script, which then picks up the file and processes it.

WebStarlogProc.app

This is the application that actually processes the log file and send the lines to Helix. This script handles errors, writes a log file (of the script's successes and failures) processes single files or batches... it does quite a bit. Feel free to study the techniques used. I won't say they are the best, but they do work.


©1999-2004 Autograph Systems
Script provided as is. No warranty expressed or implied. (You are on your own with this one!)