GBest Posted December 2, 2008 Share Posted December 2, 2008 Dear php freaks, For my client I want to build a newsletters ending system, and therefore I want to run a php script in the background. The server is running on Windows 2003 with IIS (sapi = isapi). I want to make use of the exec function in this way: <?php $root = $_SERVER['SCRIPT_FILENAME']; $rootArr = explode("\\",$root); array_pop($rootArr); $root = implode("\\", $rootArr); echo $root."<br />"; $cmd = "c:\\php\\php.exe -f ".$root."\\test_running.php"; exec($cmd, $error); echo $cmd."<br />"; echo implode(",",$error)."<br />"; echo "END"; ?> with test_running.php: <?php echo "hello world"; ?> I know the php executable is located at c:\php\php.exe, but somehow I cant get the page to be executed. Why could this be and how CAN I make it work? On my home server I can run the script just fine. Can somebody help me? Best regards, Geert Link to comment https://forums.phpfreaks.com/topic/135225-exec-php-script-in-background/ Share on other sites More sharing options...
Mark Baker Posted December 2, 2008 Share Posted December 2, 2008 You may also want to point it to a php.ini file. How do you know that it's not running, because it will be echoing its output to the Windows command shell, and you're doing nothing in your calling script to trap output generated from the exec shell. Link to comment https://forums.phpfreaks.com/topic/135225-exec-php-script-in-background/#findComment-704330 Share on other sites More sharing options...
GBest Posted December 2, 2008 Author Share Posted December 2, 2008 In that script I also make a post in the database. When i just type the url, it works, but when I run through the exec command nothing gets inserted into the database... So that means it doesn;t work Link to comment https://forums.phpfreaks.com/topic/135225-exec-php-script-in-background/#findComment-704335 Share on other sites More sharing options...
Mark Baker Posted December 2, 2008 Share Posted December 2, 2008 So that means it doesn;t work Like I say, check the php.ini to make sure that it's pointing to the correct settings. The wrong path settings can really mess up includes, and you might find that dll's aren't enabled. Make sure that you know execatly what directory you're set to while the code is running... it won't necessarily be the same as the directory your web scripts execute in. Watch out for file permissions too. Link to comment https://forums.phpfreaks.com/topic/135225-exec-php-script-in-background/#findComment-704346 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.