|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-01-10 14:28 UTC] mikesul@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 00:00:01 2025 UTC |
Description: ------------ When opening a shell on remote host with ssh2_shell than normal php output buffer mechanism does not work any more. None of the commands operation on the active ob_buffer works as exspected and describe by the PHP manual. One has to explicitly open PHP://STDOUT and frwirte to it to send messages to the client or fclose the stream returned by ssh_shell again. Which is not desireable when you have to analyze the output of remote programm before sending (new) commands to the shell/program as opening a pseudo terminal may take some time. Thus i ask you to either add some ssh2_proc function which behaves like proc_open but running remote shell/program machine instead of local shell/program or fix ssh2_shell that it returns streams which do not interfeer with default PHP://STDIN PHP://STDOUT and PHP://STDERR. I'm using mod_php for appache 1.3.27. Reproduce code: --------------- $session = ssh2_connect("localhost","2222"); ssh2_auth_password($session,$username,$password); $channel = ssh2_shell($session,"linux",NULL,1024,1,SSH2_TERM_UNIT_CHARS); echo "this is some message to client<BR/>\n"; stream_set_blocking($channel, true); fprintf($channel,"echo -e \"a\\nb\\nc\\nd" \necho ENDOFOUTPUT\n") sleep(200000); // this is necessary in order not to read back // commands sent to client before client has received them. while ( ( $line = fread($channel) ) !== false ) { echo "line \"$line\"<BR/>\n"; if ( trim($line) == "ENDOFOUTPUT" ) { break; } } fprintf($channel,"echo done\nexit\nlogout\n"); sleep(200000); // this is necessary in order not to read back // commands sent to client before client has received them. fclose($channel) echo "done with whatever"; Expected result: ---------------- this is some message to client line "a" line "b" line "c" line "d" line "ENDOFOUTPUT" done with whatever Actual result: -------------- If at all than i see: done with whatever