The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need a script written - can anyone help?

Discussion in 'General Discussion' started by eglwolf, Mar 17, 2005.

  1. eglwolf

    eglwolf Well-Known Member

    Joined:
    Jan 1, 2004
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    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.
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    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);
     
  3. eglwolf

    eglwolf Well-Known Member

    Joined:
    Jan 1, 2004
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    Chirpy - THANKS YOU SO MUCH! YOU ROCK!!!
     
Loading...

Share This Page