PHP - system command - in the background
Moderator: General Moderators
-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
PHP - system command - in the background
Hi,
I have a PHP page that calls a python script from the command line using the PHP system command:
system($command);
The python script takes about 60 secs to run, I would like to display a 'Please Wait' message on the page whilst the script is running
Does anyone have any suggestions for the best way to do this?
Thanks
I have a PHP page that calls a python script from the command line using the PHP system command:
system($command);
The python script takes about 60 secs to run, I would like to display a 'Please Wait' message on the page whilst the script is running
Does anyone have any suggestions for the best way to do this?
Thanks
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: PHP - system command - in the background
Execute it using AJAX so it's asyncronous. Or just use output buffering to flush the message to the screen. The browser will hang though without ajax.ianripping wrote:Hi,
I have a PHP page that calls a python script from the command line using the PHP system command:
system($command);
The python script takes about 60 secs to run, I would like to display a 'Please Wait' message on the page whilst the script is running
Does anyone have any suggestions for the best way to do this?
Thanks
-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
Why wouldn't this work:
Code: Select all
echo "Please wait";
system("python script.ph");-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
Code: Select all
echo "Please wait";
system("python script.py");
header("Location: http://redirect.com");-
ianripping
- Forum Newbie
- Posts: 17
- Joined: Thu Feb 05, 2004 3:20 am
- Location: Leeds, UK
AJAX, as said before. You can read about it at: http://developer.mozilla.org/en/docs/AJAX.
Basically, you need to open your PHP page and each time tell PHP to execute another program (exec.php?prog=1, exec.php?prog=2 etc...).
When PHP is done, print (with PHP) message that indicates whether the execute did well or not - AJAX will display it to the user.
In my opinion, Java is the best language to execute programs (it gives more control...).
Basically, you need to open your PHP page and each time tell PHP to execute another program (exec.php?prog=1, exec.php?prog=2 etc...).
When PHP is done, print (with PHP) message that indicates whether the execute did well or not - AJAX will display it to the user.
In my opinion, Java is the best language to execute programs (it gives more control...).