开发者

Execute shell script in the background while a page is displayed on screen to the user in php

In my application, I am running a shel开发者_Python百科l script but till the script completes executing the screen is blank. I am not able to display anything on screen. I want to display the log file to the user so till the log file is generated, i want the user to see some text content on the screen.

I read previous questions posted where they say multithreading in php is not possible.

Is there a way i can do this?


These two questions might be of some help:

1> exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile));

php execute a background process

2> ignore_user_abort(true)


I would use jQuery.

Call the page loading the php script from the main page.

Mainpage

  • Basic html page with a $(document).ready() loading the script.php page using jQuery.get()
  • At initial state, a div contains some text.
  • When success is called, load content in same div.

Link to jQuery.get() : http://api.jquery.com/jQuery.get/


These questions suggest it is and isn't possible, depending on whose answer your looking at; Multithreading in PHP

How can one use multi threading in PHP applications

You should take a look at; http://joseph.randomnetworks.com/2005/10/21/fake-fork-in-php/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜