我无法在PHP中显示SSH流的输出。这是我的代码:
$output = ssh2_exec($sshCon, $sshCommand);
stream_set_blocking($output, true);
echo stream_get_contents($output);
输出为空。该命令肯定正在运行。我也尝试了这里给出的解决方案:清空 PHP SSH2 流内容,即使有stream_set_blocking?
输出应该是进程 ID,只是为了让您知道。
谢谢!
试试phpseclib,一个纯PHP SSH实现:
<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
exit('Login Failed');
}
echo $ssh->exec($sshCommand);
?>