Thread Shell-Error durchs benutzen von ``
(36 answers)
Opened by FlorianL at 2008-01-21 15:12
Ich würde an Deiner Stelle vielleicht Date::Calc einsetzen, das vieles von Dir abnimmt...
Ich habe mir zwar nicht alles angeschaut (und ich konnte es hier nicht testen)... Code (perl): (dl
)
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 #!/usr/bin/perl use strict; use warnings; use Date::Calc qw(AddDeltaDays AddDeltaYM); my $filespath = "/home/re17830/chksize/checksize_db"; my ($day,$month,$year) = (localtime time)[3..5]; my $date = sprintf "%02d-%02d-%02d", $year % 100, $month+1, $day; my ($pyear,$pmonth,$pday) = Add_Delta_Days( $year+1900,$month+1,$day, -1 ); my ($lyear,$lmonth,$lday) = Add_Delta_YM( $year+1900, $month+1, $day, 0, -1 ); my $predate = sprintf "%02d-%02d-%02d", $pyear % 100, $pmonth, $pday; chomp(my $prechk = `echo $pday | wc -ck`); if ($prechk == 2) { $preday = "0$predaycheck"; } my $newfile = "$filespath/SizeCheck-$date\.dat"; my $oldfile = "$filespath/SizeCheck-$predate\.dat"; my @filesystem = `ls -Rlgo /`; open(REWRITE, ">$newfile"); foreach(@filesystem) { chomp(); my @line = split(/ +/); if ($line[0] =~ m/^\//g) { print REWRITE "\n$line[0]\n"; } elsif (($line[0] =~ m/^dr/g) || ($line[0] =~ m/^-r/g)) { print REWRITE "$line[2]\t\t$line[6]\n"; } else { next; } } if ($day == 28) { `rm $filespath/SizeCheck-*-\$premonth\-*`; } OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |