Leser: 1
|< 1 2 3 >| | 30 Einträge, 3 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/local/bin/perl -w
#
use warnings;
$inpdir="/opt/compuset1/rmiserver/BaslerAPI/CompusetService/error/";
opendir(LOG, "$inpdir") or die "Verz. kann nicht geoeffnet werden: $!\n";
while ($name = readdir(LOG)) {
push(@logfiles, $name);
}
@logfiles = grep(/.*\.log$/, @logfiles);
closedir(LOG);
for ($i=0;$i<=$#logfiles;$i++) {
$logfiles[$i] =~ /(.*)\.log/;
print "$1.log\n";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/local/bin/perl -w
#
use strict;
use warnings;
use Tie::File;
use File::Basename;
my $inpdir="/opt/compuset1/rmiserver/BaslerAPI/CompusetService/error/";
opendir(LOG, $inpdir) or die "Verz. kann nicht geoeffnet werden: $!\n";
my @logfiles = grep{/\.log$/}readdir(LOG);
closedir(LOG);
for my $file(@logfiles){
if(!check_log_file($inpdir,$file)){
delete_files($inpdir,$file);
}
}
sub check_log_file{
my ($dir,$name) = @_;
tie @lines,'Tie::File',$dir.'/'.$name or die $!;
for my $line(@lines){
if($line =~ /kein (?:PDF|TIFF)/){
print "Fehler gefunden\n";
return;
}
}
untie @lines;
return 1;
}
sub delete_files{
my ($dir,$name) = @_;
my ($basename) = basename($name);
unlink $basename.'.'.$_ for(qw(log inx pdf));
}
1
2
3
4
5
#benutze deine methode von file listin here um sie zu loeschen
@files = ("listoffilesgoeshere"); #heist die listen @logfiles ?
foreach $file (@files) {
unlink($file); #loescht die files
}
Unrecognized switch: -; (-h will show valid options).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!perl
#
use strict;
use warnings;
use Tie::File;
use File::Basename;
my $inpdir="/opt/compuset1/rmiserver/BaslerAPI/CompusetService/error/";
opendir(LOG, $inpdir) or die "Verz. kann nicht geoeffnet werden: $!\n";
my @logfiles = grep{/\.log$/}readdir(LOG);
closedir(LOG);
for my $file(@logfiles){
if(!check_log_file($inpdir,$file)){
delete_files($inpdir,$file);
}
}
sub check_log_file{
my ($dir,$name) = @_;
tie my @lines,'Tie::File',$dir.'/'.$name or die $!;
for my $line(@lines){
if($line =~ /kein (?:PDF|TIFF)/){
print "Fehler gefunden\n";
return;
}
}
untie @lines;
return 1;
}
sub delete_files{
my ($dir,$name) = @_;
my ($basename) = basename($name);
unlink $basename.'.'.$_ for(qw(log inx pdf));
}
1
2
Can't locate Tie/File.pm in @INC (@INC contains: /usr/local/lib/perl5/5.6.1/sun4-solaris /usr/loca /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris /usr/local/lib/perl5/site_perl/5.6.1 /usr/localerl .) at ./loeschen3.pl line 6.
BEGIN failed--compilation aborted at ./loeschen3.pl line 6.
|< 1 2 3 >| | 30 Einträge, 3 Seiten |