I need to know that If I call a php script execution command through exec command and the script execution fails due to any reason say "file not found" , then how can I find it out. I have following command :
$cmd="php testfile.php" ;
$outputfile="testoutput.txt";
exec(sprintf("%s > %s 2>&1 & echo $!", $cmd, $outputfile),$pidArr, $status);
exec command return -1 in case of error but in this case exec is executing successfully ie $status is coming 0 in my case but the "php testfile.php" command is failing, the output is getting in testoutput.txt. But I need to know the way so that I can identify it after exec if the command is failed. I could think of the option of reading testoutput.txt and grep for fail or error word, but I dont think it is reliable.
Thanks in advance!