Page 1 of 1

List all packages with exec()

Posted: Thu Jun 08, 2017 5:17 pm
by ymakux
I'm trying get a list of all available packages using PHP exec() but it returns only empty array:

Code: Select all

$cmd = '/usr/bin/sudo /usr/local/vesta/bin/v-list-user-packages json';
$return = 0;
$output = array();
exec($cmd, $output, $return);
print_r(json_decode(implode("\n", $output), true));
The same for another format type (shell, plain etc)

What's wrong?

Re: List all packages with exec()

Posted: Thu Jun 08, 2017 5:55 pm
by ymakux
Probably something related to permissions. Web API works fine

Re: List all packages with exec()

Posted: Tue Jun 13, 2017 8:50 am
by tjebbeke
Wish user are you using to execute the script? Is the user maybe not allowed to execute the sudo command?
It's better to use the API for this.