Domanda

The following code works when executed from the command prompt in windows 7 running "php test.php" (PHP 5) - output is simply "test". But when the php (v5) is run over any browser running on a localhost apache server (v2.2) it doesn't work - i.e. no output (using both straight echo, flush AND using AJAX methods). The process is started successfully (verified using proc_get_status) (means to me that permission concerns are OK too). Seems to be something to do with the pipes. Any ideas? Is there a well-known thing I'm missing?

<?php
$descriptorspec = array(
   0 => array("pipe", "r"), 
   1 => array("pipe", "w")
);
$process = proc_open("java Test", $descriptorspec, $pipes, null, null,array('bypass_shell'=>true));
fclose($pipes[0]);
echo stream_get_contents($pipes[1]);
fclose($pipes[1]);
proc_close($process);
?>
È stato utile?

Soluzione

Probably your apache server runs as "system" as a non-interactive service. Many things won't work and probably also pipes for console applications. Also, you could have permission problems because your console (where it works) has user (yours) permissions, while spawned console has system permissions.

If you really need pipes, you could try to run apache as a user (and not system) and configure the service enabling desktop interaction.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top