![]() |
![]() |
3 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
##############
# new_conf
albert
peter
johann
rolf
karin
steffen
##############
# bereinigt
albert
peter
karin
##############
# tempfile
albert (in beiden vorhanden)
peter (in beiden vorhanden)
karin (in beiden vorhanden)
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
#!/usr/bin/perl
open(GOODFILE,"<good.txt");
@GOOD_LINES = <GOODFILE>;
close(GOODFILE);
open(CHECKFILE,"<check.txt");
@CHECKLINES = <CHECKFILE>;
close(CHECKFILE);
chomp(@GOOD_LINES);
chomp(@CHECKLINES);
foreach $GOODLINE (@GOOD_LINES) {
foreach $CHECKLINE (@CHECKLINES) {
if ( $GOODLINE eq $CHECKLINE ) {
open (TEMPFILE, '>>temp.txt');
print TEMPFILE $GOODLINE."\n";
close (TEMPFILE);
}
}
}
system("/usr/bin/diff /good.txt /temp.txt > /dev/null");
if ( $? == 0 ) {
print "Config OK!"."\n";
}
else {
print "Config nicht OK!"."\n";
}
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
#!/usr/bin/perl use 5.010; use strict; use warnings; my @good = do { open my $good, '<', $ARGV[0] // 'good.txt' or die "open(<good>): $!\n"; <$good>; }; chomp @good; my %check = do { open my $check, '<', $ARGV[1] // 'check.txt' or die "open(<check>): $!\n"; map { chomp; $_ => 1; } <$check>; }; foreach (@good) { if (!$check{$_}) { print "Configuration lacks $_\n"; exit 1; } } print "Configuration is ok\n"; exit 0;
![]() |
![]() |
3 Einträge, 1 Seite |