Posts

Showing posts with the label automatic

Automatic FTP upload when content changed in folder - perl script

This was rudimentary script needed to edit more, but found interesting . #! perl -slw use strict; use Win32::ChangeNotify; use threads; #monitoring path. my $path = 'c:\folder'; my $notify = Win32::ChangeNotify->new( $path, 0, 'FILE_NAME' ); my %last; @last{ glob $path . '\*' } = (); my $count = 0; while( 1 ) { next unless $notify->wait( 10_000 ); # Check every 10 seconds $notify->reset; print $/, 'Something changed'; my @files = glob $path . '\*'; if( @files> scalar keys %last ) { my %temp; @temp{ @files } = (); delete @temp{ keys %last }; #print for keys %temp; my $k; my $v; while ( ($k,$v) = each %temp ) { my $thr1 = threads->create(\&load, $k,$count); } } else { print "A non-deletion or creation change occured"; } undef %last; @last{ @files } = (); $count = $count +1; } sub load { my...