Page 1 of 1

php script consuming CPU-usage

Posted: Sun Apr 03, 2005 8:13 am
by lnp80
Hello

(using Windows XP)
I am running a php-script and during execution it is starting another php-script (myPHP_script.php). This second php-script is running in the background and everything is working fine when i start the initial php-script from the command line. The problem starts when i try to run the php-script with Explorer or some other web-browsers -> the system then begin using a total of 100% CPU. I have tried to start "calc.exe" instead of "php myPHP_script.php" and then everything seems to be ok.

Code: Select all

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("php myPHP_script.php", 3, false);
I do not know what might be wrong and i would be wery pleased if anyone could help me solve this.

PS. I have also tried to use shell_exec() but the same problem occured. And in adition i didn't manage to use shell_exec() for having a process running in the background.

regards

Posted: Mon Apr 04, 2005 7:31 am
by Chris Corbyn
Post us the code from myPHP_script.php.... sounds like some kind a infinite loop issue :?

myPHP_script.php

Posted: Mon Apr 04, 2005 9:05 am
by lnp80
myPHP_script.php

my php-script doesnt do anything else than echo'ing 'Hello'. The script is supposed be continously checking some weather data, but when a simple hello halts the initial script i havent started on this. Have also tried to run a python script from the initial php-script but the result is the same.
My code is simply:

Code: Select all

echo 'hello';
I am not able to run any php or python scripts from the initiating php-script. But .exe files are ok. Also all, php, python and .exe are ok if the initiating php-script is started from the shell. The problem occurs when i run the initiating php-script from a web-browser!



Posted: Mon Apr 04, 2005 9:18 am
by Chris Corbyn
Hmmm... try

Code: Select all

oExec = $WshShell->Run("php.exe -f myPHP_script.php", 3, false);

the 'php -f myPHP_script.php' didnt help

Posted: Mon Apr 04, 2005 10:27 am
by lnp80
hello again

the '-f' didnt help, but i forgot to tell that what i am making is a web page residing in an apache server. From this page i want to start another php-script. Maybe the problem is the path. My apache-server'root is in 'web'

initiator code:

Code: Select all

<?
$sep = DIRECTORY_SEPARATOR;
$WshShell = new COM("WScript.Shell");
$path = "C:".$sep."web".$sep."komponenter".$sep."testfiler".$sep;
$cmd = "php -f ".$path."myPHP_script.php";
$oExec = $WshShell->Run($cmd, 3, false);
?>
myPHP_script code:

Code: Select all

<?
$fd = fopen("foo.txt", "w");
$dateTime = date("Y-m-d H:i:s ", strtotime("now"));
fputs($fd, "Hallo: ".$dateTime);
fclose($fd);
?>

Posted: Mon Apr 04, 2005 12:44 pm
by Chris Corbyn
Do you have the php installation folder correctly added to the path environament variable in windows so that you can just call php.exe without giving a full path? - Also... you say CPU hits 100%... but does the script ever execute?

i think it is some path problem

Posted: Mon Apr 04, 2005 2:46 pm
by lnp80
the environment-variable is set, I just use php (not the whole path).
I do think that the path I am using will not be correct from the apachservers point of view, since everything is working when i'm running it locally from my terminal.

But I don't know what other path I should use... The apache root is 'C:\web', and the files resides in 'C:\web\komponents'

And you are right, the script does not execute. I guess it is not found?