2018-10-19 22:26
浏览 90


I am creating a page that executes a shell script on a remote server to scan a website and outputs the results on the screen. The output can sometimes take awhile to get depending on the size of the site being scanned. Currently the script works and does what it's supposed to but the problem is when I scan larger sites it stalls and on the platform the website is being hosted on has a timeout of 30 seconds that I cannot alter.

I am wondering what the best way to keep the connection alive whether it just be sending dots to the screen or maybe something else just to keep the connection alive.

Here is my script

$ssh = new Net_SSH2('hostname');
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');

$ansi = new File_ANSI();
$ssh->exec("./ | awk 'NR >= 16 {print}'
echo $ansi->getHistory();

Any help or guidance is deeply appreciated.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

  • douzi2749 2018-10-19 22:43

    You should rather let the page load and e.g. run an AJAX request that will wait for a reply/listen on a port than trying to keep the connection alive.

    So on the user's side, it would run an ajax request (javascript) to the php url, then on success you display the result.

      url: "/thescript.php":,
      type: "POST",
      datatype: "POST"
      success: function(){
        //do display stuff

    Would probably add a reasonable timeout.

    解决 无用
    打赏 举报

相关推荐 更多相似问题