cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,216
12
313
Houston, TX
cPanel Access Level
Root Administrator
You could build a shell script that loops through all the cPanel users and greps against the mail directories which are formatted as:

/home/USERNAME/mail/DOMAIN/EMAILUSER

Where /home is the home directory
USERNAME is the cPanel user's username
EMAILUSER@DOMAIN is the email address

Note, there are also symbolic links in /home/USERNAME/mail to the above paths that are [email protected] (note the . at the start of the folder name)
 

tuxicans

Active Member
Oct 16, 2008
38
0
56
Hi,

If you have few accounts only then the following script should be enough.

cat /home/*/etc/*.*/passwd|grep -i test
 

crazyaboutlinux

Well-Known Member
Nov 3, 2007
939
1
66
Hi Tuxicans

This is really really really nice .

now suppose i want to delete any email account from the result which i got as below {e.g RED MARKED}

test:x:32183:32184::/home/abc/mail/abc.com/test:/usr/local/cpanel/bin/noshell
test:x:32013:32015::/home/def/mail/def.com/test:/usr/local/cpanel/bin/noshell
test:x:32199:32201::/home/xyz/mail/xyz.org/test:/usr/local/cpanel/bin/noshell



then which command to be used ???


Thanks again !
 
Last edited:

crazyaboutlinux

Well-Known Member
Nov 3, 2007
939
1
66
Hi David,

You could build a shell script that loops through all the cPanel users and greps against the mail directories which are formatted as:

/home/USERNAME/mail/DOMAIN/EMAILUSER

Where /home is the home directory
USERNAME is the cPanel user's username
EMAILUSER@DOMAIN is the email address

Note, there are also symbolic links in /home/USERNAME/mail to the above paths that are [email protected] (note the . at the start of the folder name)

Tuxicans has given fantastic command & no need to built a shell script.

however i also want to learn how to create shell script
(e.g which extension , path to save newly built script , script name )
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,216
12
313
Houston, TX
cPanel Access Level
Root Administrator
Hi David,




Tuxicans has given fantastic command & no need to built a shell script.

however i also want to learn how to create shell script
(e.g which extension , path to save newly built script , script name )
You can build shell scripts in a variety of languages. One common method of building shell scripts is using what's known as "Bash Scripting" - you can learn more about Bash on Wikipedia at: http://en.wikipedia.org/wiki/Bash. There are some links to websites that teach Bash Scripting at the bottom of the page.

Another common language used for building shell scripts is Perl. You can usually find a book on Perl at a local library, but you can find links to some online tutorials on the bottom of the Wikipedia article on Perl: http://en.wikipedia.org/wiki/Perl