【发布时间】:2018-01-05 09:21:04
【问题描述】:
我是第一次使用 HTML 和 PHP。我有一个 php 页面,它有一个调用 shell 脚本的提交按钮。这个 shell 脚本执行一些需要大约 10-15 分钟的任务。 单击提交按钮时,会打开一个新页面,该页面会立即打印一些信息,然后在后台运行该脚本。
但是,浏览器选项卡显示的页面仍在加载中。无论如何我可以停止加载栏。 php 代码 sn-p 看起来像这样:
if($_POST['action'] == 'Test') {
$result = liveExecuteCommand("/usr/bin/test.sh &");
}
【问题讨论】:
-
在页面加载后立即调用脚本,或者您可以使用 die() 函数停止该页面
-
没找到你吗?你能详细说明一下吗?
-
liveExecuteCommand应该做什么? -
$proc = popen("$cmd 2>&1 ;", 'r'); $live_output = ""; $complete_output = ""; while (!feof($proc)) { $live_output = fread($proc, 4096); $complete_output = $complete_output 。 $live_output;回声“$live_output”; @flush(); }