Ftp – Automatically run a script on an uploaded FTP file

ftpscriptingupload

Is there a way to run a script over a file that has been uploaded on an FTP server.

I am running ProFTP on the server and would like to process the uploaded files immediately after they are uploaded. The ways I have currently thought of are

  1. Cron Job to find new files in the FTP and process them every minute.
  2. Write a daemon to monitor the file upload log and use that information to process the file.

Is there a better way, or a directive I can set on the server to run a script on all file uploads?

Update: Linux OS

Best Answer

You don't state your OS, but if you're on a Linux box, you can hook 'inotify', which will is a kernel subsystem that fires when filesystem events happen. This should give you much better response time than cron, which only runs on one minute granularity.

The following link will get you started, but there are Perl, Python, and a bunch of other bindings available.

http://inotify-tools.sourceforge.net