I've recreated the problem with as little code as possible.
Script #1 - Call.php
<?php
exec('/usr/local/bin/php Test.php > Fork.log');
echo "Call.php";
?>
Script #2 - Test.php
<?php
echo "Test.php";
?>
The results of Fork.log are as follows:
When Call.php is run from command line
X-Powered-By: PHP/4.4.7
Content-type: text/html
Test.php
When Call.php is run from a web browser
X-Powered-By: PHP/4.4.7
Content-type: text/html
Call.php
I've tried running a shell script which calls the php with the same results, works in command line, not in the browser.
The basic behavior seems to be that any php invoked as a result of exec, shell_exec etc, is calling the original page (Script 1/Call.php) instead of the page that's actually passed (Script 2/Test.php). If I run the exec() in the background with
exec('/usr/local/bin/php Test.php > Fork.log &');
Call.php calls itself infinitely. (at which point I have to toss an exit() at the top of the file to get it to stop.)
I've seen a lot of examples for forking while trying to resolve this problem and it doesn't seem to be the syntax but more likely a configuration issue. I'm on a shared host so have little control over the environment, but if I can find the problem might be able to get it fixed.
Any help would be greatly appreciated.