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

renee
 2008-01-29 12:44
#105315 #105315
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Also unter 5.8.8 läuft es ziemlich schnell...

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
#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;
use Time::HiRes qw(time);

my $file = 'test.txt';
open my $fh, '<', $file or die $!;
my @diff = <$fh>;
close $fh;

print time,"\n";

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";
      }
   }
}

print time,"\n";


mit dieser .txt
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
/home:                                                             /home:
/home/re17830: /home/re17830:
159 .Xauthority | 106 .Xauthority
9734 .sh_history.1 | 7425 .sh_history.1
116 .sh_history.2 | 93 .sh_history.2
/home/re17830/.ssh: /home/re17830/.ssh:
/home/re17830/chksize: /home/re17830/chksize:
1613 build_checksize_db.ksh | 1600 build_checksize_db.ksh
2183 checksize | 2151 checksize
0 test.txt <
/home/re17830/chksize/checksize_db: /home/re17830/chksize/checksize_db:
1076213 SizeCheck-08-01-15.dat | 97882 SizeCheck-08-01-15.dat
1080180 SizeCheck-08-01-16.dat <
/home/re17830/scripts: /home/re17830/scripts:
/home/root: /home/root:
6927 .bash_history | 6910 .bash_history
8402 .sh_history.1 | 2130 .sh_history.1
13310 .sh_history.2 | 13304 .sh_history.2
305 .vi_history | 327 .vi_history
/home/root/.ssh: /home/root/.ssh:
3296 known_hosts | 3068 known_hosts
/home/root/scripts: /home/root/scripts:
/home/webadmin: /home/webadmin:
/home/webadmin/.ssh: /home/webadmin/.ssh:
>


Ausgabe:
Code: (dl )
1
2
3
C:\>skript.pl
1201602610.15138
1201602610.16779


Aber irgendwie sieht Dein @diff anders aus als meins... Hat sich an dem Format irgendwas geändert?
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/

View full thread Shell-Error durchs benutzen von ``