douhuan1648 2016-11-22 16:26
浏览 38

从PHP启动命令行而不阻止导航器

What I need to do : I need to launch three commands from an index.php file in the navigator in a shell without blocking the navigator on each command but each command need to wait for the previous one to finish to be able to start.

What I tried (used the first note from this link http://php.net/manual/en/function.exec.php) :

$launchGeneration = function ($appName, $id_application) {
            $cmd = "gradlew assembleDebug && cd ../../../api2 && php scriptUpdate.php " . $id_application;
            chdir("../api/tmp/" . $appName . "/");
            if (substr(php_uname(), 0, 7) == "Windows"){ 
                pclose(popen("start /B ". $cmd, "r"));  
            } 
            else { 
               exec($cmd . " > /dev/null &");   
            }
            exec($cmd);
    };

With this method, the navigator won't wait for the commands to finish but the problem is that I also need the first command to be finish before the others can start. The first one will build an application and only then the third one will modify some data in my database to change the status of the compilation from "waiting" to "done". But in this case, the status will be changed to "done" before the end of the build.

At the moment I am working on Windows but in the end, it will be running on a unix system. If it can't be done with Windows I can switch with debian.

Is there any way to launch several commands one by one without blocking the navigator ?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示