0

我想获得 ssh2_exec 命令的退出状态。我尝试了以下代码,但它给了我 jar 文件的输出,但我只想要成功或失败的状态。我怎样才能得到它,请帮忙。

$stream = ssh2_exec($connection, 'path of jar file');
stream_set_blocking($stream,true);
$output = ssh2_fetch_stream($stream,SSH2_STREAM_STDIO);
echo stream_get_contents($output);
4

1 回答 1

0

您应该改用 stderr :

$output = ssh2_fetch_stream($stream,SSH2_STREAM_STDERR);

如果没有错误,那就是成功了。

于 2016-02-21T16:09:57.547 回答