lyadmin/perl-script/user_cleanup.pl

33 lines
461 B
Perl
Raw Normal View History

#!/usr/bin/perl
use warnings;
use strict;
my $fn;
my $cmd_out;
my $dn;
my @hd;
$dn = "/home/";
opendir MYDIR, $dn or die "could not open $dn";
@hd = readdir MYDIR;
closedir MYDIR;
@hd = grep {!($_ =~ /^\..*$/)} @hd;
$fn = "/tilde/lyadmin/user_list.txt";
open FILE, "<", $fn or die "could not open $fn";
while(<FILE>){
chomp;
unless(exists( {map { $_ => 1} @hd}->{$_})){
printf("Deleting user %s\n", $_);
`userdel $_`;
}
}
close FILE