<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content="text/html; charset=windows-1257" http-equiv=Content-Type> <META name=GENERATOR content="MSHTML 8.00.6001.18876"> <STYLE></STYLE> </HEAD> <BODY><SPAN class=normal><SPAN class=normal> <DIV><FONT size=2 face=Arial>sveiki - reikia bi-directional rysio tarp konkretaus proceso (pvz ssh, ftp, mysql) ir php dalies, tam, kad suserti eile komandu, po kiekvienos nuskaitant konsoles output'a.<BR><BR>Kas idomiausia - viskas kaip ir veikia, taciau stdout'a gaunu tik uzdares stdin'a (pipe[0]) :\ - gugleje rodo keleta panasiu klausimu - tik, deja, be atsakymu.<BR><BR>bandau suvokti - kokia tuomet proc_open funkcijos prasme?</FONT></DIV> <DIV><FONT size=2 face=Arial></FONT></SPAN></SPAN> </DIV> <DIV><SPAN class=normal><FONT face=Arial><SPAN class=normal><CODE><FONT color=#000000><FONT size=2> </FONT><FONT color=#0000bb size=2><?php <BR>$descriptorspec </FONT><FONT size=2><FONT color=#007700>= array( <BR> </FONT><FONT color=#0000bb>0 </FONT><FONT color=#007700>=> array(</FONT><FONT color=#dd0000>"pipe"</FONT><FONT color=#007700>, </FONT><FONT color=#dd0000>"r"</FONT></FONT><FONT size=2><FONT color=#007700>), <BR> </FONT><FONT color=#0000bb>1 </FONT><FONT color=#007700>=> array(</FONT><FONT color=#dd0000>"pipe"</FONT><FONT color=#007700>, </FONT><FONT color=#dd0000>"w"</FONT></FONT><FONT size=2><FONT color=#007700>), <BR> </FONT><FONT color=#0000bb>2 </FONT><FONT color=#007700>=> array(</FONT><FONT color=#dd0000>"pipe"</FONT><FONT color=#007700>, </FONT><FONT color=#dd0000>"r"</FONT></FONT><FONT size=2><FONT color=#007700>) <BR>); <BR><BR></FONT><FONT color=#0000bb>$process </FONT><FONT color=#007700>= </FONT><FONT color=#0000bb>proc_open</FONT><FONT color=#007700>(</FONT><FONT color=#dd0000>'mysql -u root'</FONT><FONT color=#007700>, </FONT><FONT color=#0000bb>$descriptorspec</FONT><FONT color=#007700>, </FONT><FONT color=#0000bb>$pipes</FONT></FONT><FONT size=2><FONT color=#007700>); <BR><BR>if (</FONT><FONT color=#0000bb>is_resource</FONT><FONT color=#007700>(</FONT><FONT color=#0000bb>$process</FONT></FONT><FONT color=#007700 size=2>)) { <BR> </FONT><FONT size=2><FONT color=#ff8000>//stream_set_blocking($pipes[0],0); <BR> //stream_set_blocking($pipes[1],0); <BR><BR> </FONT><FONT color=#0000bb>fwrite</FONT><FONT color=#007700>(</FONT><FONT color=#0000bb>$pipes</FONT><FONT color=#007700>[</FONT><FONT color=#0000bb>0</FONT><FONT color=#007700>], </FONT><FONT color=#dd0000>"show databases;\n"</FONT></FONT><FONT size=2><FONT color=#007700>); <BR> </FONT><FONT color=#0000bb>sleep</FONT><FONT color=#007700>(</FONT><FONT color=#0000bb>1</FONT></FONT><FONT color=#007700 size=2>); <BR> </FONT><FONT size=2><FONT color=#ff8000>//fclose($pipes[0]); - veikia tik atkomentavus sia eilute. <BR> </FONT><FONT color=#0000bb>$rez</FONT><FONT color=#007700>=</FONT><FONT color=#0000bb>stream_get_contents</FONT><FONT color=#007700>(</FONT><FONT color=#0000bb>$pipes</FONT><FONT color=#007700>[</FONT><FONT color=#0000bb>1</FONT></FONT><FONT size=2><FONT color=#007700>]); <BR> echo </FONT><FONT color=#dd0000>"[$rez]"</FONT></FONT><FONT color=#007700 size=2>; <BR> </FONT><FONT size=2><FONT color=#ff8000>//fclose($pipes[1]); <BR> </FONT><FONT color=#0000bb>proc_close</FONT><FONT color=#007700>(</FONT><FONT color=#0000bb>$process</FONT></FONT><FONT size=2><FONT color=#007700>); <BR>} <BR></FONT><FONT color=#0000bb>?></FONT> </FONT></FONT></CODE></SPAN></FONT></SPAN></DIV> <DIV><SPAN class=normal><FONT face=Arial><SPAN class=normal><CODE><FONT color=#0000bb size=2></FONT></CODE></SPAN><BR><FONT size=2>isbandyta ir po fbsd ir po windoze.<BR>php 5.2.12 ir 5.3.0<BR><BR>dekui uz mintis</FONT></FONT></SPAN></DIV></BODY></HTML>