Need a script written - can anyone help?

eglwolf

Well-Known Member
Jan 1, 2004
190
0
166
I would like to have a script written that compares the trueuserdomain file with the accounts in home, and output a list of account in home which should be removed.

Can anyone help me with this I am not a coder, so I would not even know where to begin.
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
33
473
Go on, have a guess
Threw this together:
Code:
#!/usr/bin/perl
open (IN, "</etc/trueuserdomains") or die;
my @data = <IN>;
close (IN);
chomp @data;

my %users;
foreach my $line (@data) {
	my ($domain,$user) = split(/\s/,$line);
	$users{$user} = 1;
}

opendir (DIR, "/home") or die;
while ($file = readdir(DIR)) {
	if ((-d "/home/$file") and ($file !~ /^\./)) {
		unless ($users{$file}) {print "/home/$file is not a current cPanel user directory\n"}
	}
}
closedir (DIR);