【问题标题】:PHP - ssh2 reading output streamPHP - ssh2 读取输出流
【发布时间】:2012-06-15 21:04:04
【问题描述】:

我无法在 PHP 中显示 SSH 流的输出。这是我的代码:

$output = ssh2_exec($sshCon, $sshCommand);

stream_set_blocking($output, true);

echo stream_get_contents($output);

输出为空白。该命令肯定正在运行。我也尝试了这里给出的解决方案: Empty PHP SSH2 stream contents, even with stream_set_blocking?

输出应该是进程 ID,只是为了让您知道。

谢谢!

【问题讨论】:

    标签: php ssh


    【解决方案1】:

    试试phpseclib, a pure PHP SSH implementation:

    <?php
    include('Net/SSH2.php');
    
    $ssh = new Net_SSH2('www.domain.tld');
    if (!$ssh->login('username', 'password')) {
        exit('Login Failed');
    }
    
    echo $ssh->exec($sshCommand);
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-12
      相关资源
      最近更新 更多