473,408 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Execute php page automatically in the background ?

43
Hi guys,

I wanna to execute a php page automatically in the background,

or execute it in shell script, and set this script to execute as a cron job.

so who knows either of the two questions :
1- execute a php page automatically in the background ?
2- execute a php page in shell script ?

anyone knows how to do this ?

thanks a million.

Tanya
Jul 12 '07 #1
7 4543
pbmods
5,821 Expert 4TB
Heya, Tanya.

I'm pretty sure this will work:
Expand|Select|Wrap|Line Numbers
  1. `php /path/to/file &`;
  2.  
  3. // Alternatively, try this:
  4. pclose(popen('php /path/to/file &'));
  5.  
The '&' is important. It tells the shell not to wait for the process to exit.
Jul 12 '07 #2
tanyali
43
Heya, Tanya.

I'm pretty sure this will work:
Expand|Select|Wrap|Line Numbers
  1. `php /path/to/file &`;
  2.  
  3. // Alternatively, try this:
  4. pclose(popen('php /path/to/file &'));
  5.  
The '&' is important. It tells the shell not to wait for the process to exit.
thanks for answering first!

I tried :
`php /home/lmcelwain/public_html/R_LSM_Station/Create_Station/test.php &` ;
it returned :
php: command not found
I am wondering do I need to set up any config files in order to make shell recognize php command ?


also tried this :
pclose(popen('php /home/lmcelwain/public_html/R_LSM_Station/Create_Station/test.php &'));
it returned:
./php.sh: line 11: syntax error near unexpected token `popen'
./php.sh: line 11: `pclose(popen('php /home/lmcelwain/public_html/R_LSM_Station/Create_Station/test.php &'));'
I have no idea about this one.


looking forward to your reply.
thanks
Tanya
Jul 13 '07 #3
You could use AJAX to execute a php page through HTTP Request Object. I don't have any reference code right now, but if you look into that it should be what you need.
Jul 13 '07 #4
pbmods
5,821 Expert 4TB
Heya, Tanya.

I tried :
`php /home/lmcelwain/public_html/R_LSM_Station/Create_Station/test.php &` ;
it returned :
php: command not found
I am wondering do I need to set up any config files in order to make shell recognize php command ?
You may need to use the absolute path to the php tool. Try /usr/bin/php, /bin/php or /usr/local/bin/php. If none of these work, then there is a good chance that the PHP command-line tool is not installed on your server.

If you want to run this command from a shell script, you don't need to use the backticks.

also tried this :
pclose(popen('php /home/lmcelwain/public_html/R_LSM_Station/Create_Station/test.php &'));
it returned:
./php.sh: line 11: syntax error near unexpected token `popen'
./php.sh: line 11: `pclose(popen('php /home/lmcelwain/public_html/R_LSM_Station/Create_Station/test.php &'));'
I have no idea about this one.
This code is designed to be run from a PHP file. popen() and pclose() are PHP functions. However, you may still get the 'php not found' error as above.
Jul 13 '07 #5
tanyali
43
heya, pbmods.

yes, I want to run this command from a shell script.

I tried :
pclose(popen(php /home/lmcelwain/public_html/R_LSM_Station/Create_Station/test.php &));
and it returned:
./test.sh: line 9: syntax error near unexpected token `popen'
./test.sh: line 9: `pclose(popen(php /home/lmcelwain/public_html/R_LSM_Station/Create_Station/test.php &));'

and also the first method, none of that three exists.
well, how can I install the PHP command-line tool on my server ?
I am using apache2

thanks ,
Tanya

Heya, Tanya.



You may need to use the absolute path to the php tool. Try /usr/bin/php, /bin/php or /usr/local/bin/php. If none of these work, then there is a good chance that the PHP command-line tool is not installed on your server.

If you want to run this command from a shell script, you don't need to use the backticks.



This code is designed to be run from a PHP file. popen() and pclose() are PHP functions. However, you may still get the 'php not found' error as above.
Jul 25 '07 #6
tanyali
43
Heya, Pbmods,

it worked,

I checked the php was installed in the dir : /usr/bin/ and what I am using is php5 instead of php, so I used the code ( bash ) :

`/usr/bin/php5 /home/lmcelwain/public_html/R_LSM_Station/Create_Station/test.php &`

and it worked !

thanks a million !!! Pbmods
Tanya

Heya, Tanya.



You may need to use the absolute path to the php tool. Try /usr/bin/php, /bin/php or /usr/local/bin/php. If none of these work, then there is a good chance that the PHP command-line tool is not installed on your server.

If you want to run this command from a shell script, you don't need to use the backticks.



This code is designed to be run from a PHP file. popen() and pclose() are PHP functions. However, you may still get the 'php not found' error as above.
Jul 26 '07 #7
pbmods
5,821 Expert 4TB
Heya, Tanya.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Jul 26 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Elie Grouchko | last post by:
Hi In Page1.asp I am calling Server.Execute("Page2.asp"). Before calling Server.Execute(), I set an application variable to a value that it is important for me to know that it doesn't get...
1
by: Carl Johansen | last post by:
I'm not sure of the best way to do what I want. Users of my website want to run reports that take a long time to generate. This is what I would like to happen: 1. User requests aspx page 2....
6
by: SF RVN | last post by:
Hmmmm.. a wee bit of a problem: Background default.htm has a left-aligned table serving as a 'navigation menu' and a right-aligned iFrame (named 'viewframe') serving as the 'target' for...
16
by: expertware | last post by:
Dear friends, My name is Pamela, I do not know anything about javascript, but I would like to ask if it offers a solution to this problem of mine. I have an image on a web page within a css...
13
by: Bijoy Naick | last post by:
My project contains multiple aspx pages. Many of these pages have code-behind that use several helper functions. Instead of copying each helper function into each aspx page, I am thinking of...
4
by: frog | last post by:
Hi, all: I tried to call Server.Execute in Application_Start and got exception. Any help is appreciated You might ask why I want to do that in the first place. Well, I need to start a...
7
by: pb | last post by:
Hi all, I have some code that automatically generates a url depending on user selections. This url is then set as a hyperlink and the user clicks on the link that has the target as an iframe on...
4
by: john_smith_nebraska | last post by:
I am using VISTA . I have IIS enabled . I installed VS 2005 successfully. Under old ASPX you knwo you go to inetpub wwwroot and run a test default.aspx file to see if it executes properly....
4
by: pankajsingh5k | last post by:
Hi guys, i only know basic css mainly the formatting part.... i want to create a side panel for my website that looks like a small window that has a blue header and blue borders and slightly...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.