Hallo an alle!
danke schonmal im Voraus für eure Infos!!
ich hänge wieder einmal bei einem Script - ich bekomme von 7zip logfiles (erste Codepassage)in ein Verzeichnis, bei welchen ich zuerst auf das Modifytime losgehe und dann möchte ich noch via openfile das File nach einer bestimmten Klausel durchsuchen -- ich habe jetzt den untenstehenden Code erstellt und getestet - ich bekomm aber eine Fehlermeldung (weiter unten)bzw. weiss ich nicht, ob mein Code so wie ich ihn geschrieben habe auch stimmt - hat vielleicht jemand eine Idee, wie ich das besser machen könnte?
lg Micahelf
:
Fileinhalt von Logfile aus 7zip
7-Zip (A) 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03
Scanning
Creating archive G:\Export\KI.7z
Compressing KI.DMP
Compressing KI.LOG
Everything is Ok
das ist mein Script
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/perl
use strict;
use warnings;
require "sendmail.pl";
##
### Definitionen
###
my $mailbodyfile = 'D:\\admin\\perl\\temp\\SENDMAIL_BODYFILEZR1.txt';
my $export_dir = 'd:\\admin\\tablespace\\export';
my @errors;
###
### Prozeduren
###
sub send_mail {
my ($subject_ref, $error_ref) = @_;
### sendmail.pl braucht den Body als File => erstellen
open SENDMAILBODY, '>'.$mailbodyfile or die "Sendmail Bodyfile '$mailbodyfile' kann nicht erstellt werden! ($!)";
print SENDMAILBODY @$error_ref;
close SENDMAILBODY;
sendmail($$subject_ref, $mailbodyfile);
return 0;
}
sub exporttrace {
if (opendir STUNDENDIR, $export_dir) {
foreach my $file (map "$export_dir\\$_", grep !/^\./, readdir EXPORTDIR) {
my $mtime = (stat("$export_dir\\$file"))[9];
(my $sid) = $file =~ /\\([^\\_]+)_/;
if (time() - $mtime > 24*60*60) {
push @errors, "Export von $sid wurde noch nicht fertiggestellt.\n";
}
if (open FILE, '<'.$file) {
if (/Everything is Ok/) {
push @errors, "Export von sid $sid OK.\n";
}
else
{
push @errors, "beim Export von sid $sid traten fehler auf.\n";
}
}
close FILE;
} else {
push @errors, "File '$file' konnte nicht geöffnet werden\n";
}
}
closedir EXPORTDIR;
} else {
push @errors, "Verzeichnis '$export_dir' konnte nicht geöffnet werden\n";
}
}
### Hauptteil
###
&exporttrace;
my $mail_subject; ### sendmail.pl setzt Win32::NodeName() davor!
if (@errors) {
$mail_subject .= "TESTING_FEHLER!!!";
} else {
$mail_subject .= "TESTING_OK";
}
### Informations E-Mail versenden
&send_mail(\$mail_subject,\@errors);
### Programm mit Status 999 beenden, wenn ein Oracle-Fehler gefunden wurde
exit 999 if @errors;
Fehlermeldung:
D:\admin\perl\bin>perl.exe d:\admin\perl\scripts\exportcheck.pl
syntax error at d:\admin\perl\scripts\exportcheck.pl line 48, near "} else"
syntax error at d:\admin\perl\scripts\exportcheck.pl line 53, near "}"
Execution of d:\admin\perl\scripts\exportcheck.pl aborted due to compilation errors.