You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

57 lines
1.5 KiB

#!/usr/bin/env perl
use strict;
use warnings;
use FileHandle;
my $file = shift();
my $dir = shift();
if ( (!defined $file) || (!defined $file) ){
print "auditshell_create_sessionfiles <logfile> <dir>\n";
exit(1);
}
chdir($dir);
unless(chdir($dir))
{
die "Error: Can't change directory!: $!";
}
open( INFILE, "<$file" ) || die "input-file '$file' could not be opened";
my $fdcache = {};
while (my $zeile = <INFILE>) {
if ($zeile =~m /auditshell\.(typescript|timing)\.(.*?): (.*)$/){
chomp($zeile);
my $type = $1;
my $ident = $2;
my $line = $3;
if ( !exists $fdcache->{$ident}){
$fdcache->{$ident} = {};
print "Create $ident.typescript.base64\n";
$fdcache->{$ident}->{typescript} = FileHandle->new("> $ident.typescript.base64");
print "Create $ident.timing.base64\n";
$fdcache->{$ident}->{timing} = FileHandle->new("> $ident.timing.base64");
}
my $fd = $fdcache->{$ident}->{$type};
print $fd $line."\n";
}
}
close(INFILE);
foreach my $ident(keys %{$fdcache}){
close $fdcache->{$ident}->{typescript};
close $fdcache->{$ident}->{timing};
system("base64 -d $ident.typescript.base64 |gzip -c > $ident.typescript.gz");
system("base64 -d $ident.timing.base64 |gzip -c > $ident.timing.gz");
unlink("$ident.timing.base64");
unlink("$ident.typescript.base64");
print "removed $ident.typescript.base64, created $ident.typescript.gz\n";
print "removed $ident.timing.base64, created $ident.timing.gz\n";
}