Nathan Rixham wrote:
Hi Guys,

Hoping somebody out there may have come across this one, possible functionality request depending on responses.


$descriptor = array(
   0 => array("pipe", "r"),
   1 => array("pipe", "w"),
   2 => array("pipe", "w")
);
$process = proc_open('mysql', $descriptor, $pipes);

fwrite($pipes[0], 'show databases;');
echo stream_get_contents($pipes[1]); //won't work, crash, time out.. nothing returns as we need to..

fwrite($pipes[0], 'show databases;');
fclose($pipes[0]); // note the fclose
echo stream_get_contents($pipes[1]);

I don't want to fclose pipes[0] though, as i want to keep it open and keep writing to it, alternating with reading from pipes[1] and [2]..
so a replacement for fclose, or an fflush on stdout that works?

The problem appears to be that nothing is returned to php until the stdin pipe is closed, even if I write hundreds of commands to it.

I think that's controlled by the process you're calling rather than a php thing.

For example, smtp connections do this until you enter a '.' on a single line.

ie the process you're calling doesn't know when to stop reading from stdin until you close the conn.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to