PHP/SSH:如果他们满足多个页面,则如何输出(回声)SSH结果?

发布于 2025-02-07 23:44:10 字数 824 浏览 3 评论 0原文

我尝试通过SSH连接到设备(在我的情况下是华为交换机),在网页上执行命令和打印结果。 如果我的$ ssh_input等于'display arp | i 10.100.1.1'我将在网页上取得下一个结果,并且在网页上相同的结果 - 都可以正常工作。

输出一页

但是,当我尝试做$ ssh_input时I 10.100' - 结果在终端中变成了多个页面,我可以按“空间”下一页。

输出多个页面

但是在网页上,此情况无限加载页面,因为据我了解,据我了解,众所周知,代码未完成

$connection = ssh2_connect($ip, 22);
ssh2_auth_password($connection, 'login', 'password');
$stream = ssh2_exec($connection, $ssh_input);
stream_set_blocking($stream, true);
$stream_out = ssh2_fetch_stream( $stream, SSH2_STREAM_STDIO );
echo "<pre>";
echo stream_get_contents($stream_out);
echo "</pre>";

我如何通过多个页面修改代码以进行输出?

I am try connect by SSH to device (in my case Huawei switch), execute command and print result on web page.
If my $ssh_input equal like 'display arp | i 10.100.1.1' i have next result in terminal and same result on web page - all work fine.

output one page

But when I try do $ssh_input equal like 'display arp | i 10.100' - result became with multiple page in terminal and i can press 'Space' next page.

output multiple page

But on web page this case result infinite load of page because, as I understand, code don't complete

$connection = ssh2_connect($ip, 22);
ssh2_auth_password($connection, 'login', 'password');
$stream = ssh2_exec($connection, $ssh_input);
stream_set_blocking($stream, true);
$stream_out = ssh2_fetch_stream( $stream, SSH2_STREAM_STDIO );
echo "<pre>";
echo stream_get_contents($stream_out);
echo "</pre>";

How I can modify my code for output that case with multiple page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文