I am facing an issue with the exec command in php. I am trying to run a package ( ffmpeg.exe ) through exec command in php, but my php script runs successfully on alternate runs i.e. first run is fine, second run gives internal server error 500, then third run is successful but fourth run give me the same error. I am going crazy over this but am not able to figure out if its a fastCGI error or a php error. My environment details are: OS - Windows 7 Home Premium, service pack 1; IIS version 7.5.7600; php version 5.3.28
My php script is very trivial :-
echo "hello";
echo '</br>';
$cmd_to_execute = 'ffmpeg.exe -f concat -i list.txt -c copy output.mp4 -y';
echo $cmd_to_execute;
echo '</br>';
$f = exec($cmd_to_execute,$a,$b);
var_dump($a);
var_dump($b);
var_dump($f);
echo "finished";
? >
when it runs successfully: the output it generates is:
hello
ffmpeg.exe -f concat -i list.txt -c copy output.mp4 -y
array(0) { } int(0) string(0) "" finished
When it fails, the page displays following information:
Module FastCgiModule
Notification ExecuteRequestHandler
Handler PHP53_via_FastCGI
Error Code 0x800703e3
This goes on alternatively - all odd runs are successful and all even runs give error. I have also tried to run the same command on command prompt and it runs successfully every time. Please help.
An old question I know, but I was having exactly the same problems with a php script failing every other time when using exec(). This was also causing issues for other very simple php scripts which never had any issues in the past.
I was running a batch script which had a 'pause' at the end. As soon as I removed the pause from the .bat my php script runs every time. So it would seem the php process is not closing cleanly even though it apparently completes ok. It then needs another run to fail which resets the process..?
Anyway, if anyone has this issue, look into how the first (successful) process is ending.
User contributions licensed under CC BY-SA 3.0