Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    189
    Likes Received:
    0
    Trophy Points:
    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.
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    21
    Trophy Points:
    463
    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);
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. eglwolf

    eglwolf Well-Known Member

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

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice