0

I followed many of ways in windows to make a command run without interrupting browser. Whenever I try to:

exec("ping 8.8.8.8") 

it makes browser to wait for process to complete.

After completion of process it echoes the output.So what i want is to run a command(like ping) without interrupting browser and store output in variable.

In my case I want to show a dialogue until ping is over and show output afterwards.

I tried:

exec(start \B myexecutable.exe)

without success.Also tried

pclose(popen(start \B myexecutable.exe))

Any suggestion is appreciated.

3
  • you may want to try php.net/manual/en/function.shell-exec.php Note: This function is disabled when PHP is running in safe mode. Commented Sep 19, 2017 at 10:09
  • 1
    PHP doesn't work that way. You can't load something in the browser and then send it something else from the same PHP execution. The more sensible thing to do would be to make an AJAX request on page load, then remove the dialogue and show the output when you get a response. Commented Sep 19, 2017 at 10:11
  • as mentioned above, ajax is the way forward if you want the page to be available and just wait for a response. Commented Sep 19, 2017 at 10:22

1 Answer 1

1

Probably late answer but for me this works on Windows & Linux:

if (isWindows()) {
    pclose(popen("start /B php myfile.php -args", 'r'));
} else {
    exec("php myfile.php -args");
}

You need to activate the php directive

ignore_user_abort(true)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.