我正在带有数据包处理程序的路由器上运行ssh-> exec。
第一次通话效果很好-我看到了结果。
第二个呼叫永远不会得到任何结果。在php日志中,我看到以下消息:
3939行上的C:\ temp \ php \ Net \ SSH2.php过早关闭了连接
我需要做些什么来保持连接打开足够长的时间才能进行第二次通话吗?
代码片段:
function packet_handler($str) {
echo "results from remote unit: $str \n";
}
$sCmd="who";
$ssh->setTimeout(3);
$ssh->exec("$sCmd", 'packet_handler'); // I see results for this call
//usleep(3000000);
$ssh->exec("$sCmd", 'packet_handler'); // I never see results for this call