【问题标题】:Output of Net_SSH2 is being cut off?Net_SSH2 的输出被切断了?
【发布时间】:2019-07-21 20:37:55
【问题描述】:

我正在使用 phpseclib (Net_SSH2) 通过 PHP 运行命令。问题是输出似乎在较长的行上被切断。这是一个问题,因为我正在使用 PHP 从每一行中查找某些细节(现在大部分细节都被切断了)。

这是我当前的代码:

set_include_path(__DIR__ . '/phpseclib');
include("Net/SSH2.php");

$ssh = new Net_SSH2('example.com', 22);
if (!$ssh->login('testing', "123456")) exit('Login Failed');

$shell = $ssh->exec('ps aux');
echo $shell;

这是应该回显的内容:

267745  4370  0.0  0.1 7148 2220  -  SNJ  21:56   0:00.02 sh /home/public/crons/syncing.sh
267745 86056  0.0  0.0 4240 1600  -  SNCJ 22:15   0:00.00 sleep 10
267745 37349  0.0  0.1 7864 3512 14  SNsJ 16:36   0:01.14 -bash (bash)
267745 86089  0.0  0.1 6992 2228 14  RN+J 22:15   0:00.00 ps aux

这就是回声:

267745  4370  0.0  0.1  7148 2220  -  SNJ  21:56   0:00.02 sh /home/public/cron
267745 86056  0.0  0.0  4240 1600  -  SNCJ 22:15   0:00.00 sleep 10
267745 37349  0.0  0.1  7864 3512 14  SNsJ 16:36   0:01.14 -bash (bash)
267745 86099  0.0  0.1  6992 2228  -  RNsJ 22:15   0:00.88 ps aux

这是上例中的问题行:

267745  4370  0.0  0.1 7148 2220  -  SNJ  21:56   0:00.02 sh /home/public/crons/syncing.sh

什么会导致这种情况发生?

我目前使用的是 phpseclib 1.0.11。

【问题讨论】:

    标签: php linux ssh phpseclib


    【解决方案1】:

    引用https://github.com/phpseclib/phpseclib/issues/1385

    似乎$ssh->setWindowColumns(...) 可能会做你想做的事。默认情况下,窗口列数为 80,除非您设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-10
      • 2012-03-27
      • 2017-07-08
      • 1970-01-01
      • 2021-04-18
      • 1970-01-01
      • 2017-05-29
      • 1970-01-01
      相关资源
      最近更新 更多