I can pass back output of the executed script, but I get no error output if the script errors out.
// This is a file that doesn't exists, for testing
$command = './path/to/non/existing/script.sh';
$commandOutput = exec($command, $commandOutput); // works but no error output
//passthru($command, $commandOutput); // works but error output was 127 not file not found
//$commandOutput = escapeshellcmd($command);
echo "The Output:\n|".$commandOutput."|\n";
var_dump($commandOutput);
The Output:
||
I would like the output of the error message:
The Output:
|file not found|
How or what function/parameter would do this?