I have following php script in which I am trying to execute a command on Windows and print it's output. I have tried system(), shell_exec(), passthru() and exec().
$cmd = $_POST['cmd'];
$result = array();
exec($cmd, $result);
foreach ($result as $line ){
echo $line."<br>";
}
exec($command, $array) is the closest to my expectation of printing everything when a command is executed. I wish to print everything even though it's an error. But it only prints when command is executed successfully.
How to achieve it ?