简体   繁体   中英

Output of Net_SSH2 is being cut off?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM