personal blog related to technology, coding and publishing.
Kqueue hell!
I’m having a bad day programming-wise. I’m trying to learn how to implement kqueue on a Mac OS X 10.4.11 server.
I need to monitor a directory for changes, and update a database table with the changes (file added – add to db as new row; file removed – remove from db table).
Anyone out there know anything that might help? I’ve been searching for hours now!
Update: (2009-03-30)
I’ve “solved” the problem by using a combination of AppleScript, PERL, and MySQL. Here’s what I did:
- Created a folder action that monitors a folder on my PDF repository server for any additions/deletions
- Once the folder action is fired, the AppleScript checks to ensure the file added/deleted is a PDF (ignoring any other issues in the directory)
- If the file added/deleted is a PDF, the AppleScript fires one of two PERL scripts (perl_dbAdd.pl or perl_dbDelete.pl), passing as well the added/deleted filename
- The correct PERL script attempts a connection to the MySQL database on my MySQL/Web server (still internal network) and creates or deletes (as appropriate) a record for the PDF file
- The PERL file quits itself, and nobody is the wiser on my PDF repository server
This system seems to be working well. One thing I’d like to check for is within my PERL files: ensure that the PDF file actually exists (or not) depending on the corresponding PERL action.
Finally, I think I’ll create a PHP file that will test each database record against the actual file structure – there’s 4159 PDF files recorded in the database, and I’d like to be sure the ActionScript/PERL combo is working as expected.
| Print article | This entry was posted by Chad Edge on March 19, 2009 at 3:20 pm, and is filed under Apple, Personal, code, technology. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |