Php check if shell_exec command was successful
Try using exec
:
$output = array();//Each line will be assigned to this array if any are generated.$result1 = exec($command, $output, $return);if ($return != 0){ // error occurred}else{ // success}
You can do this:
$output = shell_exec('ls -lart');echo "<pre>$output</pre>";
and validate the output.
But according to the manual:
Note: This function can return NULL both when an error occurs or the program produces no output. It is not possible to detect execution failures using this function. exec() should be used when access to the program exit code is required.