QuadRoM

Registered
Oct 4, 2012
2
0
1
cPanel Access Level
Root Administrator
These functions only return results for a specified user. I tried them with 'root' user but they didn't work.
I must be able to get all sub domains.

I need a list like 'List Subdomains' page at web host manager. I don't know how that page works.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

You may need to do it this way instead:

http://forums.cpanel.net/f5/list-all-domains-96649.html#post435237

Where you loop through the accounts and get a list of the subdomains or addon domains.

Otherwise, in command line without using the API, you could do the following:

Code:
or i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do awk '/sub_domains/{c=5;next}c{c--;print}' /var/cpanel/userdata/$i/main ;done
This won't show the files it is grabbing, though, to show the accounts. It is pulling the data from /var/cpanel/userdata/username/main where username is the cPanel username by reading the sub_domains portion of the file and returning the lines below it.
 

000

Well-Known Member
Jun 3, 2008
310
13
68
...
Code:
or i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do awk '/sub_domains/{c=5;next}c{c--;print}' /var/cpanel/userdata/$i/main ;done
Many thanks, so good command :) I only "fixed" ONE letter (f):
Code:
for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do awk '/sub_domains/{c=5;next}c{c--;print}' /var/cpanel/userdata/$i/main ;done
Some idea about how we can get subdomains from ONLY thisdomain.com ?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
4,483
566
273
cPanel Access Level
Root Administrator
@000 - I would recommend using the following API call:

Code:
uapi --user=username DomainInfo list_domains

That will return data similar to the following:'

Code:
# uapi --user=username DomainInfo list_domains
---
apiversion: 3
func: list_domains
module: DomainInfo
result:
  data:
    addon_domains: []

    main_domain: domain.com
    parked_domains: []

    sub_domains:
      - subtest.domain.com
  errors: ~
  messages: ~
  metadata: {}

  status: 1
  warnings: ~