M
mac8500
Simple script:
I run it .... server$ ./group.pl ./tmp/test.group.* > group.csv (where
* is servernames).
more ./tmp/test.group.server1
This is to output the group id's in a file readable by excel BUT i need
to find the differences between the servers.
I tought i could put my first pass threw the file and put the entire
line in a $ so i could compare the lines between them and if they don't
match just print it ... but i couldn't get that to work ... i'm sure it
easy i just can't get a grasp on a simple solution.
Thanks.
***!!!***!!!*** server1
system:0
staff:1
bin:2
sys:3
adm:4
uucp:5
mail:6
security:7
cron:8
printq:9
audit:10
nobody:4294
usr:100
#!/usr/bin/perl
my @servers;
while(<>) {
my($line) = $_;
chomp($line);
if ($line =~ /\*\*\*/) {
$currentserver = substr $line, 16;
push (@servers,$currentserver);
} else {
( $login, $userid, $gid, ) = split( ':' );
chomp($gid);
$users{ $login }{ $currentserver } = $gid;
}
}
#
# Main program.
#
print "USERNAMES";
foreach $servername (sort @servers) {
print ",".$servername
}
print "\n";
foreach $login (sort keys %users) {
print $login;
foreach $servername (sort @servers) {
if ($users{$login}{$servername} >= 0) {
print ",".$users{$login}{$servername};
} else {
print ", ";
}
}
print "\n";
}
close FILES;
I run it .... server$ ./group.pl ./tmp/test.group.* > group.csv (where
* is servernames).
more ./tmp/test.group.server1
This is to output the group id's in a file readable by excel BUT i need
to find the differences between the servers.
I tought i could put my first pass threw the file and put the entire
line in a $ so i could compare the lines between them and if they don't
match just print it ... but i couldn't get that to work ... i'm sure it
easy i just can't get a grasp on a simple solution.
Thanks.
***!!!***!!!*** server1
system:0
staff:1
bin:2
sys:3
adm:4
uucp:5
mail:6
security:7
cron:8
printq:9
audit:10
nobody:4294
usr:100
#!/usr/bin/perl
my @servers;
while(<>) {
my($line) = $_;
chomp($line);
if ($line =~ /\*\*\*/) {
$currentserver = substr $line, 16;
push (@servers,$currentserver);
} else {
( $login, $userid, $gid, ) = split( ':' );
chomp($gid);
$users{ $login }{ $currentserver } = $gid;
}
}
#
# Main program.
#
print "USERNAMES";
foreach $servername (sort @servers) {
print ",".$servername
}
print "\n";
foreach $login (sort keys %users) {
print $login;
foreach $servername (sort @servers) {
if ($users{$login}{$servername} >= 0) {
print ",".$users{$login}{$servername};
} else {
print ", ";
}
}
print "\n";
}
close FILES;