-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomm_groups.pl
More file actions
94 lines (85 loc) · 2.56 KB
/
comm_groups.pl
File metadata and controls
94 lines (85 loc) · 2.56 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/perl
#
use warnings;
use strict;
use LinWin::Format qw(parse_grp);
## begin user documentation stuff
use Getopt::Long;
use Pod::Usage;
use Data::Dumper;
my $comm_groups_VER = '0.1';
my $opt_debug = 0;
my ( $dbfile, $extantfile, $opt_help, $opt_man, $opt_versions );
GetOptions(
'debug=i' => \$opt_debug,
'help!' => \$opt_help,
'man!' => \$opt_man,
'versions!' => \$opt_versions,
'dbfile=s' => \$dbfile,
'extantfile=s' => \$extantfile,
) or pod2usage( -verbose => 1 ) && exit;
pod2usage( -verbose => 1 ) && exit if ( $opt_debug !~ /^[10]$/ );
pod2usage( -verbose => 1 ) && exit if defined $opt_help;
pod2usage( -verbose => 2 ) && exit if defined $opt_man;
print
"\nModules, Perl, OS, Program info:\n",
" DBIx::Class $DBIx::Class::VERSION\n",
" Pod::Usage $Pod::Usage::VERSION\n",
" Getopt::Long $Getopt::Long::VERSION\n",
" strict $strict::VERSION\n",
" Perl $]\n",
" OS $^O\n",
" comm_groups.pl $comm_groups_VER\n", " $0\n", "\n\n"
&& exit
if defined $opt_versions;
## end user documentation stuff
open DBFILE, '<', "groupsdb";
my %dbfile;
while ( <DBFILE> ) {
chomp( my $line = $_ );
my $RHgroup = parse_grp($line);
print Dumper $RHgroup;
my $gid = $RHgroup->{GID};
$dbfile{$gid} = $RHgroup;
#print Dumper %dbfile;
#my $wait = <STDIN>;
}
close DBFILE;
open PPFILE, '<', "groupcheck";
my %ppfile;
while ( <PPFILE> ) {
chomp( my $line = $_ );
my $RHgroup = parse_grp($line);
print Dumper $RHgroup;
my $gid = $RHgroup->{GID};
$ppfile{$gid} = $RHgroup;
}
close PPFILE;
open GROUPSLIST, '>', "groupslist";
foreach my $gid ( sort { $a <=> $b } keys %ppfile ) {
printf GROUPSLIST "%s%30s\n", $dbfile{$gid}->{GROUP_NAME},
$ppfile{$gid}->{GROUP_NAME};
}
foreach my $gid ( sort { $a <=> $b } keys %dbfile ) {
print "The group: $dbfile{$gid}->{GROUP_NAME} \n";
#if ($dbfile{$gid}->{users} eq $ppfile{$gid}->{users}) {
# print "They have the same users\n";
#}
my @dbusers = sort @{$dbfile{$gid}->{users}};
my @ppusers = sort @{$ppfile{$gid}->{users}};
next if @dbusers ~~ @ppusers;
print "dbusers = @dbusers\n";
print "Only in db: ";
my %onlydb;
@onlydb{ @dbusers } = undef;
delete @onlydb{ @ppusers };
my @onlydb = keys %onlydb;
print "@onlydb\n";
print "Only in pp: ";
my %onlypp;
@onlypp{ @ppusers } = undef;
delete @onlypp{ @dbusers };
my @onlypp = keys %onlypp;
print "@onlypp\n";
my $wait = <STDIN>;
}