PHP shell_exec not working when adding options Ubuntu Apache2

Viewed 37

I'm trying to run a command from PHP to disconnect a user from OpenVPN Access Server

    $output = shell_exec('sacli --user test --client_reason EXPIRED DisconnectUser');
    echo "<pre>$output</pre>";

This won't work and doesn't disconnect user, I confirmed the full command works in the terminal.

If I just use shell_exec('sacli'); or shell_exec('sacli --help'); it will echo successfully:

sacli: No command specified

Use --help to show usage

Any help is appreciated,

Thanks!

1 Answers

The most common problem here is that you're not running it with sudo or as root user. Do that and it should work fine

Related