dourong8495 2012-05-09 06:47
浏览 13
已采纳

popen句柄跨持久连接

I am trying to execute a command by using popen and then print out its progress via AJAX. I have found this post extremely helpful and got the AJAX to script exchange working fine. The problem is that every time there is an async GET to test from ajax, the handle on popen is repeated. If I have the shell only run once, then the handle is no longer valid. I can't figure out how to make $handle be persistent accross requests.

public function test()
{
      chdir('my dir');
      $handle = popen('make install 2>&1','r');
      echo fread($handle, 2096);


}

There will only be one user requesting this at a time....only used on the Admin back end of things. The output from AJAX is always, "Making install in src".

  • 写回答

1条回答 默认 最新

  • dongyan1841 2012-05-09 08:16
    关注

    You can't do that. You'll have to run the 'make install' process in the background (e.g. via exec()) and redirect it's output to a file/pipe that you can read from when executing the AJAX requests.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度