duanji1043 2019-07-19 22:20
浏览 110

Net_SSH2的输出正在切断?

I'm using phpseclib (Net_SSH2) to run a command with PHP. The problem is that the output appears to be cut off on longer lines. This is a problem because I'm using PHP to find certain details from each line (and most of those details are now cut off).

Here's my current code:

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;

This is what should be echoing:

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

This is what is echoing:

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

This is the problematic line in the example above:

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

What would be causing this to happen?

I'm currently using phpseclib 1.0.11.

  • 写回答

1条回答 默认 最新

  • duanhuan7750 2019-07-21 12:37
    关注

    Quoting https://github.com/phpseclib/phpseclib/issues/1385,

    Seems like $ssh->setWindowColumns(...) might do what you want. By default window columns is 80, unless set by you.

    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致