Results 1 to 1 of 1
Jun 10, 2009, 17:01 #1
- Join Date
- Jun 2009
- 0 Post(s)
- 0 Thread(s)
Executing an application from PHP
Windows XP Pro
Service Pack 3 / dotNet 3.5
In a website project I have to convert mathematical formulas into .png images with LaTeX in my PHP code. The problem I have is that when I call LaTeX from PHP, the program takes for ever to execute and PHP crash after the timeout have been reached.
And this, even if everything went normally without any error with latex.exe. However, in command line, this process takes a fraction of a second to execute without any error too.
My homework so far:
Like suggested in another forum, I have added this to my php file:
exec($command . " >NUL");
exec("start /B " . $command);
pclose(popen("start ". $command, "r"));
$output = array();
$result = null;
$return = exec($command, $output, $result);
exec('start /B "'.$command.'"', $output, $return);
Once the timeout problem resolved, I don't have any error in the Apache logs.
In php.ini, safe_mode is Off and disable_functions is Off like suggested elsewhere.
I have tried some simple commands to test for permissions, like "dir *.*" and "copy from to"... Every things works fine, with the dir command, the folder is listed in the output array. With the copy command, the file is copied and I have the message "1 file(s) copied." in the array. All of these tests with other command went fine and took a fraction of a second to execute.
I had the idea to look what was going on in the windows task manager to see what is happening. It's weird, when I execute latex.exe through PHP, the processor usage goes up to 90% to 100% during 2 minutes 40 secondes or so, until the process stop and then everything comes back to normal. When I do the same command in command line, I can't even see the process in the task manager, it's too fast. And CPU usage doesn't even budge. This isn't normal?
I've tried to execute the PHP script directly from the command line (C:\WWW\lc.workspace.com\site>php index.php) and guess what !? Everything goes fine and latex.exe is executed in a fraction of a second. Could it be Apache blocking the execution of the program??
So here I am... I'm a bit lost now.
Thanks for your help and suggestions.