Here is a quick Perl script I wrote to monitor a folder for new files of a certain extension. When an .epl2 file is created, it is immediately printed on lp0.
#notify.pl
#!/usr/bin/perl -w
use strict;
use SGI::FAM;
use File::Copy; my $conn = new SGI::FAM;
$conn->monitor( "/home/bprenatt/" ); my $extension = "epl2";
my $watch = "create"; while (1)
{
my $event = $conn->next_event;
my $len = length $extension;
my $string = substr($event->filename, -$len);
if($event->type eq $watch && $string eq $extension)
{
my $file = $event->filename;
print $file, "\n";
copy($event->filename, "/dev/lp0");
}
}




No user commented in " notify.pl "
Follow-up comment rss or Leave a TrackbackLeave A Reply