Some extensions may use the command-line utilities that Plesk provides to administrators as an alternative to performing operations from the GUI. The Command-Line Interface (CLI) has the same functions as XML API, but an operation output is provided as a plain text rather than an XML tree. Learn more about the command-line utilities in the following documents:
A command-line call is performed by pm_ApiCli::call, the first argument is the utility name, and the second argument is the array of options and their values.
pm_ApiCli::call can only be called from command-line scripts, and not via operations in the Plesk GUI.
The following example retrieves information about the current Plesk license key:
The output should be similar to the following:
In more complex situations, divide a call into arguments and add each argument as an array item. For example:
should be transformed to:
If you need to retrieve only a certain output parameter, for example, a result code, call pm_ApiCli::call with the third parameter which defines the parameter to output, for example:
The $result variable will be assigned the result code.
The directory /<product-root>/admin/bin/ contains utilities that are run with elevated privileges. In addition to this, an extension can bring some utilities that should be run with elevated privileges. Such utilities are placed in the directory /<product-root>/admin/bin/modules/$MODULE_NAME.
Note: Privileged utilities are only available in Plesk for Linux.
You can run such utilities by using the method callSbin:
$result = pm_ApiCli::callSbin('my-utility');
By default, the utility called my-utility will be searched for in the directory /<product-root>/admin/bin/modules/$MODULE_NAME. If the utility is not found, it will then be searched for in the directory /usr/local/psa/admin/bin/.