source: LATMOS-Accounts/import/check-passwd @ 610

Last change on this file since 610 was 591, checked in by nanardon, 15 years ago
  • apply chomp to the correct variable
File size: 750 bytes
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6my ($passwd1, $passwd2, $field) = @ARGV;
7
8sub parse_passwd {
9    my ($file) = @_;
10    my %attr;
11    if (open(my $fh, '<', $file)) {
12        while (my $line = <$fh>) {
13            chomp($line);
14            my @fields = split(':', $line);
15            $attr{$fields[0]} = $fields[$field];
16        }
17        close($fh);
18    } else {
19        die "Can't open $file";
20    }
21    return %attr;
22}
23
24my %attr1 = parse_passwd($passwd1);
25my %attr2 = parse_passwd($passwd2);
26
27foreach my $user (sort keys %attr1) {
28
29    if (!exists($attr2{$user})) {
30        next;
31    }
32    my $val1 = $attr1{$user} || '';
33    my $val2 = $attr2{$user} || '';
34
35    if ($val1 ne $val2) {
36        print "$user: `$val1' ne `$val2'\n";
37    }
38}
Note: See TracBrowser for help on using the repository browser.