Create a Log file of files copied to a Public Folder, Add to a Perl script a log of files Uploaded

OK, this really is a two part question, here's what currently happens, approx. 8 photographers copy 100s of .eps files to a Public/Shared folder (a Mac running OSX), these files are then uploaded using a perl script run as a cron job, see link below to a previous question for this script.

Part 1
Is there a way to keep track/log of each file copied (date stamped ip address of computer which uploaded file?) to the Public/Shared folder whether this is a perl script or any other way

Part 2
Modify/add to the upload script to also log each file it has uploaded

This is just to give me an audit trail from the upload Mac

Much appreciated in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Part 1 - it depends on how the photographers copy the files to the Mac.  If it is ftp, sftp, or some other remote copy, the server should be able to configure logging.  If it is a direct copy onto the Mac from their camera or whatever, there probably isn't (one of the fabulous things HURD would have made easy).

Part 2 - this should work.  It is a modified copy of the final version of the script from the previous question.
use strict;
use warnings;
use File::Find;
my $username = "xxxxxxx"; #will fill in with user
my $password = "xxxxxxx"; #will fill in with users password
my $SearchDirectory = '/path/to/search';
my $DestDirectory = '/path/to/dest';

open LOG, '>>/path/to/logfile' or die "could not write to the log: $!";
my $StartTime = time;
find(\&found, $SearchDirectory);

close LOG;
sub found {
    my $mtime = (stat($File::Find::name))[9];
    return unless -f _;            #Skip non normal files (eg: directories/pipes/links...)
    return if -d _;                #Skip directories
    return unless /\.(pdf|eps)$/;  #Skip anything without .pdf or .eps extension
    return unless $StartTime - $mtime > 120;
    my $cmd = qq{/usr/bin/curl -F "overwrite=1" -F "filedata=\@$_" -u $user:$passwd  -s "http://$host/webnative/upload?$DestDir"};
    system("$cmd > /tmp/send_file");
    #Do you want to check to see if it was successful?
    if($?) {
        warn "Error with $File::Find::name\n";
    print LOG timestamp(), ':  copied ', $File::Find::name, "\n";
    unlink($File::Find::name) or warn "Could not remove '$File::Find::name': $!\n";

sub timestamp {
    my ($sec, $min, $hour, $mday, $mon, $yr) = localtime();
    $yr += 1900;
    return sprintf '%d/%02d/%02d $d:%d:%d', $yr, $mon, $mday, $hour, $min, $sec;

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mce-man-itAuthor Commented:
Thanks for the script going to give it a go, shortly.

The photographers just mount the Public folder via afp on there desktops and drag the files to the folder.
mce-man-itAuthor Commented:
Got the script working thanks for your help just needed a couple of tweeks, i've posted the amends just in case somebody else finds it useful, the line my $host just needed adding back in also just needed to tweek the open log line, i've used the path to where the mac stores its other logs and it is viewable in the Console app, in the line return sprintf there was a $ instead of a %.

As to the first part i'm going to see if turning on logging in the AppleFileService works for logging files copied to the shared folder.

Thanks again for your time
my $host = 'xx.xx.xx.xx';

open(LOG, ">>/Library/Logs/Upload.log") or die "could not write to the log: $!";

return sprintf '%d/%02d/%02d %d:%d:%d', $yr, $mon, $mday, $hour, $min, $sec;

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Mac OS X

From novice to tech pro — start learning today.