开发者

PHP Using ssh2_shell() with socket_select()

开发者 https://www.devze.com 2023-03-15 07:42 出处:网络
I\'m using php to open an ssh session. e.g.: $stream = ssh2_shell($connectio开发者_JAVA百科n, \'vt102\', null, 80, 24, SSH2_TERM_UNIT_CHARS);

I'm using php to open an ssh session.

e.g.:

$stream = ssh2_shell($connectio开发者_JAVA百科n, 'vt102', null, 80, 24, SSH2_TERM_UNIT_CHARS);

I can read the stream with:

$content=stream_get_contents($stream);

In order to monitor the stream I want to connect it to a socket. So that I can use socket_select()

Is this even possible?


No - ssh is a layer of protocol on top of a socket - you can't inject code between the layers) but socket_select operates at the socket layer.

But in PHP there is an additional layer on top of the ssh layer - the stream - and you can use stream_select() on a set of streams (which can include stuff other than ssh)


You could use phpseclib, a pure PHP SSH implementation, and then do stream_select($ssh->fsock) or socket_select($ssh->fsock).

0

精彩评论

暂无评论...
验证码 换一张
取 消