Obtaining username from domain name in shell script

ashworth102680

Active Member
May 3, 2007
26
1
153
I have a list of domains I wish to automate some tasks on through the command line via a script. I already have the list of domains, but some of the cPanel tasks I want to work with require the account username.

Is there a way to programmatically obtain the account's username from a given domain name or hostname?

Once I tackle this, the rest is easy, so I appreciate your help!
 

ashworth102680

Active Member
May 3, 2007
26
1
153
After much, much, much searching ...I found this. This got me in the right direction.

Code:
while read domain; do ACCT=$(grep -l DNS=$domain /var/cpanel/users/*); echo $domain `basename $ACCT`; done < domains_to_move.txt
Hopefully it will help someone else someday.
 
  • Like
Reactions: kduvall