views:

43

answers:

3

In my application, I am running a shell 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?

A: 

These questions suggest it is and isn't possible, depending on whose answer your looking at; http://stackoverflow.com/questions/590684/multithreading-in-php

http://stackoverflow.com/questions/70855/how-can-one-use-multi-threading-in-php-application

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

imbadatjquery
+1  A: 

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/

oimoim
+1  A: 

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)

zengr