Wednesday 25 September 2013

how to make PHP execute a shell script as a certain user

the first thing would be to add the user to the sudoers list with visudo.
this is the bash:
sudo -u USERNAME COMMAND
so then this is the PHP script:
shell_exec('sudo -u USERNAME COMMAND');
so then put this in context:
<?php
    $result=shell_exec('COMMAND');
    echo ($result);
?>

No comments:

Post a Comment