Skip Navigation

Generate a list of PHP versions being used by accounts on a WHM server.

  • PHP
  • WHM

Something I noticed after seeing a colleague trawl through accounts on a WHM to get PHP versions was how painful that process was. This script makes it a one-liner.

Generates a list in the following format:

ac6cdt,7.4
ac6insig,7.1

The script does the following:

  • Loops through each user within the /var/cpanel/users/ directory
  • Uses the selectorctl command to retrieve the PHP version configured for each account
  • Outputs the account name and corresponding PHP version in a comma-separated format
  • Loops through each user in /var/cpanel/users/, uses selectorctl to retrieve the PHP version configured for each account, and outputs the account name and PHP version in a comma-separated format.

    Output a comma separated list of WHM account names and PHP version numbers.
    for user in /var/cpanel/users/*;do if [[ ! "${user##*/}" = system ]]; then php="$(selectorctl -c -u "${user##*/}" 2>&1)";echo "${user##*/},${php%%$'\t'*}";fi;done