to sum it up, i am reading /etc/group, taking the list of users from three
groups (listed in @domains) and then matching each of the users to their
entry in /etc/passwd and printing the line to a file that has the name of
their group.
as it stands, this script only manages to write the passwd information for
the first user listed in the /etc/group array.
#!/usr/bin/perl
@domains = qw(lunarmedia motion reboot);
$groupfile = "group.txt";
$passfile = "pass.txt";
for $one(@domains) {
open FH, $groupfile or die $!;
while (<FH>) {
@group = split /:/, $_;
if ( $one eq $group[0] ) {
@$one = split /,/, $group[3];
}
}
close FH;
open FH, $passfile or die $!;
open NH, ">$one" or die $!;
while (<FH>) {
$line = $_;
@entry = split /:/, $line;
for $each(@$one) {
if ( $each eq $entry[0] ) {
print NH $line;
}
}
}
close NH;
close FH;
}