note 125145 added to function.ssh2-fetch-stream
| From: | ingo at baab dot de | Date: | Thu, 25 Jun 2020 15:47:00 +0000 |
| Subject: | note 125145 added to function.ssh2-fetch-stream | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214807@lists.php.net to get a copy of this message | ||
In addition to the last post (13 years ago) from Dennis K. I corrected two typos (constant
SSH2_STREAM_STDIO was misspellt) and removed (too many) brackets - this code works:
<?php
$stdout_stream = ssh2_exec($connection, "lsssss -la");
$sio_stream = ssh2_fetch_stream($stdout_stream, SSH2_STREAM_STDIO);
$err_stream = ssh2_fetch_stream($stdout_stream, SSH2_STREAM_STDERR);
stream_set_blocking($sio_stream, true);
stream_set_blocking($err_stream, true);
$result_dio = stream_get_contents($sio_stream);
$result_err = stream_get_contents($err_stream);
echo 'stderr: ' . $result_err;
echo 'stdio : ' . $result_dio;
?>
----
Server IP: 45.112.84.4
Probable Submitter: 103.51.166.36 (proxied: 2003:e3:770b:1:7fa:3eb1:ac27:6e7d)
----
Manual Page -- http://php.net/manual/en/function.ssh2-fetch-stream.php
Edit -- https://master.php.net/note/edit/125145
Del: integrated -- https://master.php.net/note/delete/125145/integrated
Del: useless -- https://master.php.net/note/delete/125145/useless
Del: bad code -- https://master.php.net/note/delete/125145/bad+code
Del: spam -- https://master.php.net/note/delete/125145/spam
Del: non-english -- https://master.php.net/note/delete/125145/non-english
Del: in docs -- https://master.php.net/note/delete/125145/in+docs
Del: other reasons-- https://master.php.net/note/delete/125145
Reject -- https://master.php.net/note/reject/125145
Search -- https://master.php.net/manage/user-notes.php