[英]How to get exit status of PHP ssh2_exec command?
我想獲取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);
您應該改用stderr:
$output = ssh2_fetch_stream($stream,SSH2_STREAM_STDERR);
如果沒有錯誤,那就成功了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.