Thread Shell-Error durchs benutzen von `` (36 answers)
Opened by FlorianL at 2008-01-21 15:12

FlorianL
 2008-01-25 14:11
#105153 #105153
User since
2007-05-18
142 Artikel
BenutzerIn
[default_avatar]
Hallo mal wieder :)

Also... Das Script funktioniert nun, allerdings dauert es extrem lange bis das ergebniss kommt, woran könnte das liegen?!

Code: (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
xtest11 # time ./checksize.pl /home 11
/home/re17830
.Xauthority 106 159 Diff: 53
.sh_history.0 18 3858 Diff: 3840
.sh_history.1 3154 9734 Diff: 6580
.sh_history.2 93 6679 Diff: 6586
SizeCheck.diff 0 256 Diff: 256
SizeCheck.ksh 1605 4096 Diff: 2491
/home/root
.bash_history 6653 11498 Diff: 4845
.sh_history.0 15910 16326 Diff: 416
.sh_history.1 1846 9036 Diff: 7190
.sh_history.2 13288 13462 Diff: 174
.sh_history.3 5934 6356 Diff: 422
.sh_history.4 3272 3402 Diff: 130
.vi_history 311 333 Diff: 22
smit.log 43945 84044 Diff: 40099
smit.script 6541 8125 Diff: 1584
smit.transaction 9541 10779 Diff: 1238
/home/root/.ssh
known_hosts 3068 3296 Diff: 228

real 3m13.819s
user 2m59.065s
sys 0m0.039s
xtest11 #


Hier nochma der aktuelle code so wie er durchgelaufen ist:

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
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
#!/usr/bin/perl
use strict;
use Data::Dumper;

my $filespath = "/home/re17830/chksize/checksize_db/";

if (defined $ARGV[0]) {} else {
                print("Error: No argument\n\nUsage: checksize <path> <day>\n");
                exit 0;
}

chomp(my $mountpt = $ARGV[0]);
chomp(my $day = $ARGV[1]);

chomp(my $month = `date +%m`);
chomp(my $premonth = ($month -1));
if ($month == 01) {
        $premonth = 12;
}

chomp(my $year = `date +%y`);
chomp(my $preyear = ($year - 1));

my $file = "$filespath\SizeCheck-$year\-$month\-$day\.dat";
my $monthfile = "$filespath\SizeCheck-$year\-$premonth\-$day\.dat";
my $yearfile = "$filespath\SizeCheck-$preyear\-$premonth\-$day\.dat";

if (-T "$file") {} else {
        $file = "$monthfile";
}

my @fslist = `ls -Rlgo $mountpt`;

my $tmpfile = "/tmp/SizeCheck.tmp";
open(REWRITE, ">$tmpfile");
print REWRITE "$mountpt\:\n";

foreach(@fslist) {
        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";
        }
}

my @diff = `sdiff $file $tmpfile \|egrep \[\:\\\<\\\>\\\|\]`;

my @order;
foreach (@diff ){
   if ( $_ =~ m/^(.+):\s+\/.+:$/) {
      push @order, [$1."\n"];
   }
   elsif ( $_ =~ m/(^\d+)\s+(.+)\s+(.)\s+(\d+)\s+(.+)\s+$/ ) {
      if ($3 eq "\|") {
         push @{ $order[-1] },"\t$2\t$1\t$4\t" . "Diff: " . abs($1 - $4) . "\n";
      }
      elsif ($3 eq "\<") {
         push @{ $order[-1] }, "\tNew File:\t$5\tSize: $4\n";
      }
      elsif ($3 eq "\>") {
         push @{ $order[-1] },"\tFile deleted:\t$5\n";
      }
   }
}

for( @order ){
   next if @$_ == 1;
   print $_ for @$_;
}

View full thread Shell-Error durchs benutzen von ``