Hallo,
die Idee von Linuxer ist perfekt - funktioniert richtig gut.
Da die Frage kam... wenn ein Installer sehr lange läuft, möchte ich halt nicht die ganze Zeit daneben sitzen, sondern nur, wenn er eine Eingabe verlangt. Dies ist in meinem Fall der Zeitpunkt, wenn die Files nicht mehr aktualisiert werden. Dann wird eine Mail generiert mit dem "Haupt-LogFile" - daraus erkenne ich, ob ein Fehler/Eingabe vorliegt oder dieser schlichtweg noch Zeit benötigt.
Ein Problem habe ich allerdings noch mit dem Mailversand... bekomme zwar ein File angehängt, jedoch ist dieses leer.
Hat hier noch jemand einen Tipp?
@linuxer: Danke für den Hinweis! Arbeite auf Windows ... daher nichts mit find, awk oder ähnlichem :(
Und hier das coding - vielleicht hilft es jemanden:
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
use Sys::Hostname;
use Net::SMTP;
use File::Find::Rule;
$SID = <SYSTEM>;
$local_host = hostname();
$mailServer = "<MAILSERVER>";
$from = "$ABSENDER\@$local_host";
$to = "Test@TEST.de";
my $output = "F:\\temp\\out\\output.txt";
my $directory = "F:\\Ziel\\log";
my $timelimit = time - (60 * 15);
my @files = File::Find::Rule->file()
->mtime( ">$timelimit" )
->in( $directory );
if (@files[0] ne '' )
{
printf "Alles Gut/n";
}
else
{
printf "Pruefen/n";
open(DATA,"F:\\<INSTDIR>\\log\\Console.log");
$newline = 1;
for ($i=-1; seek(DATA,$i,2); $i--) {
read DATA,$char,1;
if ($char eq "\n") {$i--; $newline++;}
last if ($newline > 20);
$string = $char.$string;
}
close(DATA);
@last20lines = split(/\n/, $string);
printf "=============";
printf "@last20lines";
printf "=============";
open (DATEI, ">>$output") or die $!;
print DATEI "@last20lines";
close (DATEI);
$smtp = Net::SMTP->new($mailServer);
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: SUM Installer benoetigt Eingabe\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-type: multipart/mixed; boundary=\"frontier\"/n");
$smtp->datasend("\n--frontier/n");
$smtp->datasend("Content-type: text/plain/n");
$smtp->datasend("Content-Type: application/text; name=\"output.txt\"/n");
$smtp->datasend("Content-Disposition: attachment; filename=\"output.txt\"/n");
$smtp->datasend("/n");
$smtp->dataend();
$smtp->quit;
}
Last edited: 2015-11-27 18:23:58 +0100 (CET)