Jump to content

exec php script in background


GBest

Recommended Posts

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

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.