Perl
Jump to navigation
Jump to search
check open files and send alarm if needed
open and print file with name matching
bash-2.05# cat perl_procesor.pl
#!/usr/bin/perl
$path = shift;
$path = "." unless $path;
opendir( DIR, $path ) or die "Can't open $path: $!";
while ( $entry = readdir( DIR ) ) {
$type = ( -d "$path/$entry" ) ? "dir" : "file"; # $path is crucial!
if ($type eq dir){
next;
}
if ($entry =~ m/done/){
open (FILE,$entry);
while ($line2print = <FILE>) {
if ($line2print =~ m/test/){
#system("perl /export/home/scripts/test/test_savegroup.sh") ;
system("./test_print.pl");
}
}
close (FILE);
$entry2 = $entry;
$entry2 =~ s/done/DON/;
#print "$entry2\n";
rename ($entry,$entry2);
}
}
closedir( DIR );