Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Running shell scripts with PHP and collecting the results

General discussions related to php

Moderators: macek, egami, gesf

Running shell scripts with PHP and collecting the results

Postby numbenator » Wed Feb 13, 2013 9:12 am

Hi all

Im a little confused although i am in new territory so if i have got something blatentley wrong im soz but any help would be appreciated.

I have a shell script that i am able to run fine on the linux command line but i effectively want to run this script after the user submits a form and i want it to run in the background.

I thought as a stepping stone what i would do would be to put the required execution of script in a php file on it's own just to get a feel for how to do things but i have come up with some problems.

The php script i am running is ::
:-x
Code: Select all
$handle = pclose(popen('./AWR-analyze.sh upload/StevesCompany72ede6f3c97cc8850e5726bea8b49d83/aw*.txt > upload/StevesCompany72ede6f3c97cc8850e5726bea8b49d83/StevesCompany.csv', 'r'))
echo "done"


It actually works but "done" is not rendered until the script has executed.

Now i get really confused.
Although the script executes fine... ( it collates information from txt files to a csv ) .. It should also output the progress and results. ( which it does ono the command line ) If i run this on the command line there are status messages show as the files are processed and then a "completed successfully" comment.

Firstly, i want the script to run aside of the page processing. I think it's called running as a child.... but i also need to dump the results somewhere so that i can pick them up with another script.

As said. Im not entirely sure im completely on track so any help would be really be welcome.

Cheers

Steve
numbenator
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Feb 13, 2013 9:09 am

Re: Running shell scripts with PHP and collecting the result

Postby seandisanti » Wed Feb 13, 2013 1:02 pm

why do it with a shell script instead of just doing it in your php file?
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 773
Joined: Mon Oct 01, 2012 12:32 pm

Re: Running shell scripts with PHP and collecting the result

Postby numbenator » Wed Feb 13, 2013 1:47 pm

Because the client has delivered a shell script. Its a pretty hectic process to extract the information and would take too long to understand exactly whats going on.

So.. I want to use the script but runit in the background.
I cant see it could be that hard. As said in post it wrks on the command line. I just want to run it with php and some how collect the results

Any ideas?
numbenator
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Feb 13, 2013 9:09 am


Return to PHP General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron