Try this:
<?php
$ret = exec("su -c /path/to/command -s /bin/bash -l otheruser", $out, $err);
var_dump($ret);
var_dump($out);
var_dump($err);
?>
More Info: http://us3.php.net/manual/en/function.exec.php https://www.php.net/manual/en/function.exec.php
Also, if you are expecting the exec command to ask you for the password for the other user (as it did in the linux command line) - it won't work, exec command isn't interactive. You'll need to pass the password on the command, inline.
Try this:
<?php
$ret = exec("su -c /path/to/command -s /bin/bash -l otheruser", $out, $err);
var_dump($ret);
var_dump($out);
var_dump($err);
?>
More Info: http://us3.php.net/manual/en/function.exec.php
Also, if you are expecting the exec command to ask you for the password for the other user (as it did in the linux command line) - it won't work, exec command isn't interactive. You'll need to pass the password on the command, inline.
Try this:
<?php
$ret = exec("su -c /path/to/command -s /bin/bash -l otheruser", $out, $err);
var_dump($ret);
var_dump($out);
var_dump($err);
?>
More Info: https://www.php.net/manual/en/function.exec.php
Also, if you are expecting the exec command to ask you for the password for the other user (as it did in the linux command line) - it won't work, exec command isn't interactive. You'll need to pass the password on the command, inline.
Try this:
<?php
$ret = exec("su -c /path/to/command -s /bin/bash -l otheruser", $out, $err);
var_dump($ret);
var_dump($out);
var_dump($err);
?>
More Info: http://us3.php.net/manual/en/function.exec.php
Also, if you are expecting the exec command to ask you for the password for the other user (as it did in the linux command line) - it won't work, exec command isn't interactive. You'll need to pass the password on the command, inline.