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.

Obtaining username from domain name in shell script

Discussion in 'cPanel Developers' started by ashworth102680, Nov 15, 2012.

  1. ashworth102680

    ashworth102680 Active Member

    Joined:
    May 3, 2007
    Messages:
    26
    Likes Received:
    1
    Trophy Points:
    3
    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!
     
  2. ashworth102680

    ashworth102680 Active Member

    Joined:
    May 3, 2007
    Messages:
    26
    Likes Received:
    1
    Trophy Points:
    3
    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.
     
    kduvall likes this.
Loading...

Share This Page