note 82130 added to function.proc-open

From: Date: Fri, 28 Mar 2008 10:15:54 +0000
Subject: note 82130 added to function.proc-open
Groups: php.notes 
Request: Send a blank email to php-notes+get-137665@lists.php.net to get a copy of this message
Some functions stops working proc_open() to me. This i made to work for me to communicate between two php scripts: <?php $abs_path = '/var/www/domain/filename.php'; $spec = array(array("pipe", "r"), array("pipe", "w"), array("pipe", "w")); $process = proc_open('php '.$abs_path, $spec, $pipes, null, $_ENV); if (is_resource($process)) { # wait till something happens on other side sleep(1); # send command fwrite($pipes[0], 'echo $test;'); fflush($pipes[0]); # wait till something happens on other side usleep(1000); # read pipe for result echo fread($pipes[1],1024).'<hr>'; # close pipes fclose($pipes[0]);fclose($pipes[1]);fclose($pipes[2]); $return_value = proc_close($process); } ?> filename.php then contains this: <?php $test = 'test data generated here<br>'; while(true) { # read incoming command if($fh = fopen('php://stdin','rb')) { $val_in = fread($fh,1024); fclose($fh); } # execute incoming command if($val_in) eval($val_in); usleep(1000); # prevent neverending cycle if($tmp_counter++ > 100) break; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 88.212.16.23 ---- Manual Page -- http://www.php.net/manual/en/function.proc-open.php Edit -- https://master.php.net/note/edit/82130 Del: integrated -- https://master.php.net/note/delete/82130/integrated Del: useless -- https://master.php.net/note/delete/82130/useless Del: bad code -- https://master.php.net/note/delete/82130/bad+code Del: spam -- https://master.php.net/note/delete/82130/spam Del: non-english -- https://master.php.net/note/delete/82130/non-english Del: in docs -- https://master.php.net/note/delete/82130/in+docs Del: other reasons-- https://master.php.net/note/delete/82130 Reject -- https://master.php.net/note/reject/82130 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137665) next »