Topic awaiting preservation: need help monitoring folder |
|
---|---|
Author | Thread |
Maniac (V) Inmate From: there...no..there..... |
posted 02-27-2006 21:18
I need to be able to monitor a folder which clients are going to be uploading files. I have it that they can't delete files once uploaded but I need to have the folders monitored to shoot an email when something is uploaded. Such as username and file name and date of upload. |
Maniac (V) Inmate From: raht cheah |
posted 02-27-2006 22:52
I assume you're using straight FTP instead of an uploading script? I assume this because the uploading could be made to report after upload. |
Maniac (V) Inmate From: there...no..there..... |
posted 02-28-2006 00:11
yeah just straight FTP and I don't think LAMP is installed either. quote:
|
Maniac (V) Inmate From: raht cheah |
posted 02-28-2006 02:17 |
Maniac (V) Mad Scientist From: :morF |
posted 02-28-2006 05:07
Actually all you'd need it to do is, perhaps, store one value: the date and time of when it last executed. From that it can check the date and time the file was put onto the server, and determine which files are 'new' from that. It will save a lot of time in the long-run if the contents of the directory start to encompass a lot of file. |
Maniac (V) Inmate From: raht cheah |
posted 02-28-2006 05:14 |
Maniac (V) Inmate From: there...no..there..... |
posted 02-28-2006 20:10
quote:
|
Maniac (V) Inmate From: raht cheah |
posted 02-28-2006 22:54
quote:
quote:
|
Maniac (V) Inmate From: there...no..there..... |
posted 02-28-2006 23:57
ah...ok I gotcha. quote:
|
Paranoid (IV) Inmate From: Madison, Indiana, USA |
posted 03-01-2006 17:54
CPrompt: What Operating System is this running on? code: find directory -newer time-stamp-file -print >> list-of-new-files touch time-stamp-file
|
Maniac (V) Inmate From: there...no..there..... |
posted 03-01-2006 19:18
yeah, it's RedHat. I take it that is a bash script? Not real familiar with it code: $directory = 'files'; //directory se are working with $resc = opendir($directory); //open the directory if (!$resc) { //error handling echo "Problem opening directory $directory. Error: $php_errormsg"; exit; } $files = array(); //put the files in an array while ($filename = readdir($resc)) { //loop through directory and grab all file names if (is_file($directory . '/' . $filename)) { $files[] = $filename; // Add to the array } } $cnt = count($files); //see how many files are in the directory for ($i = 0; $i < $cnt; $i++) { echo "<b>" . $files[$i] . "</b> <br />"; // Display filename or do whatever }
code: echo date("F d Y h:i:s.", filectime($filename));
|
Maniac (V) Inmate From: there...no..there..... |
posted 03-01-2006 20:35
OK, I actually got the PHP script to work as far as displaying the file name and the "filectime". |
Paranoid (IV) Inmate From: Madison, Indiana, USA |
posted 03-02-2006 05:27
If you want to get a list of new files every time the cron runs change the >> to >. That will cause the command to truncate the file before it writes the new list. code: #! /bin/bash /usr/bin/find .... /bin/touch ...
code: #! /bin/bash time=`/bin/date "+%y%m%d%H%M%S"` filename="$time-file.lst" /usr/bin/find directory -newer time-stamp-file -print > $filename /bin/touch time-stamp-file |