FAST CGI error for exec command in PHP

4

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.

php
exec
fastcgi
asked on Stack Overflow Sep 23, 2014 by Sachin G

1 Answer

0

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.

answered on Stack Overflow Jan 26, 2016 by BStone

User contributions licensed under CC BY-SA 3.0