473,320 Members | 1,713 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,320 software developers and data experts.

Execute code automatically

wj
Hi all,

I wonder if it is possible to execute PHP-code automatically. Is it
for example possible to sent an e-mail every day at lets say 9.00 pm
automatically to adresses from a database?

Thanx,
WJ
Jul 17 '05 #1
8 3092
wj wrote:
I wonder if it is possible to execute PHP-code automatically. Is it
for example possible to sent an e-mail every day at lets say 9.00 pm
automatically to adresses from a database?


If you have the PHP command-line binary you can set up a cron job to run
"php filename.php" at a certain time.

Otherwise set up a cron job to run something like wget to fetch the file
from your webserver, which will execute the script.

I'm assuming you understand how the cron system works, if not try "man
crontab"

--
Jasper Bryant-Greene
Cabbage Promotions
Jul 17 '05 #2
*** wj wrote/escribió (30 Aug 2004 01:59:10 -0700):
I wonder if it is possible to execute PHP-code automatically. Is it
for example possible to sent an e-mail every day at lets say 9.00 pm
automatically to adresses from a database?


Under Linux/Unix: crontab

Under Windows: Window's scheduled tasks

All you need is a PHP script than can run from command line.

--
-- Álvaro G. Vicario - Burgos, Spain
-- Questions sent to my mailbox will be billed ;-)
--
Jul 17 '05 #3

"wj" <wz*@jongnederland.nl> ???????/???????? ? ???????? ?????????:
news:e8**************************@posting.google.c om...
Hi all,

I wonder if it is possible to execute PHP-code automatically. Is it
for example possible to sent an e-mail every day at lets say 9.00 pm
automatically to adresses from a database?

Thanx,
WJ


PHP has no tools to do that, but you can use other programs
*nix: crontab, win: at to execute your script

Jul 17 '05 #4
Alvaro G Vicario wrote:
*** wj wrote/escribió (30 Aug 2004 01:59:10 -0700):
I wonder if it is possible to execute PHP-code automatically. Is it
for example possible to sent an e-mail every day at lets say 9.00 pm
automatically to adresses from a database?

Under Linux/Unix: crontab

Under Windows: Window's scheduled tasks

All you need is a PHP script than can run from command line.

you also need a command line which can execute PHP scripts! and (in a
windows environment at least) setting that up is not a trivial task.

sadara
Jul 17 '05 #5
*** Sadara escribió/wrote (Mon, 30 Aug 2004 12:35:24 +0200):
you also need a command line which can execute PHP scripts! and (in a
windows environment at least) setting that up is not a trivial task.


I've just made a little test (never tried it before actually) and
apparently worked fine without any problem (I didn't even need to add
php.exe to PATH). Which difficulties did you mean?

--
-+ Álvaro G. Vicario - Burgos, Spain - ICQ 46788716
+- http://www.demogracia.com (la web de humor para mayores de 100 años)
++ «Sonríe, que te vamos a hacer una foto para la esquela»
--
Jul 17 '05 #6
On Mon, 30 Aug 2004 11:25:52 +0200, Alvaro G Vicario wrote:
All you need is a PHP script than can run from command line.


Actually, you don't even need that. You can use a text-based browser to
connect to your webserver and run a script, and even have HTTP GET
variables passed to the script.

Example, on Linux/PHP/Apache with Links browser and cron:

crontab (this is all on one line! Note backslashes at the end of lines)
=======
01 11 * * * /usr/bin/links -dump \
http://localhost/script.php?var1=butt&var2=nugget > \
home/jeff/logs/scrpt.php.log
script.php
==========
<? print_r($_GET) ?>

....something along those lines.

I'm sure Windows has a text-only browser like links or lynx available.
later...
--
Jeffrey D. Silverman | je**********@jhu.edu **
Website | http://www.newtnotes.com

(** Drop "pants" to reply by email)

Jul 17 '05 #7
Alvaro G. Vicario wrote:
*** Sadara escribió/wrote (Mon, 30 Aug 2004 12:35:24 +0200):
you also need a command line which can execute PHP scripts! and (in a
windows environment at least) setting that up is not a trivial task.

I've just made a little test (never tried it before actually) and
apparently worked fine without any problem (I didn't even need to add
php.exe to PATH). Which difficulties did you mean?


In most setups you will have no difficulty running PHP scripts from the
command line. Provided php.exe is in your PATH somewhere (Alvaro
probably didn't need to add it as it was already in the PATH somewhere)
you can just run

php [script filename]

or, to supress HTTP headers:

php -q [script filename]

and the script will execute.

--
Jasper Bryant-Greene
Cabbage Promotions
Jul 17 '05 #8
*** Jasper Bryant-Greene wrote/escribió (Tue, 31 Aug 2004 16:49:40 +1200):
In most setups you will have no difficulty running PHP scripts from the
command line. Provided php.exe is in your PATH somewhere (Alvaro
probably didn't need to add it as it was already in the PATH somewhere)
you can just run


What I meant is that I used the full path:

C:\BLAH\PHP\PHP.EXE -q D:\DATA\test.php

I do such things all the like (like when I need to add a tool to my text
editor's menus), it's not a great deal ;-)
--
-- Álvaro G. Vicario - Burgos, Spain
-- Questions sent to my mailbox will be billed ;-)
--
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian Quigley | last post by:
Hi, is there some code i can use to automatically execute some HTML form code when a page is loaded ? Thanks, Brian
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...
5
by: Gustavo Randich | last post by:
Hello, I'm writing an automatic SQL parser and translator from Informix to DB2. Now I'm faced with one of the most difficult things to translate, the "foreach execute procedure" functionality...
4
by: cmrchs | last post by:
Hi, executing the following on a local drive works fine : FileStream wLog; wLog=File.OpenRead(@"d:\Log.txt"); but executing the same code on a network drive creates a...
2
by: Deere | last post by:
Keep in mind I'm an old guy who is learning .net. In asp classic I had a trash can icon in my shopping cart that would delete a record. In trying to accomplish the same in gridview I've used a...
7
by: tanyali | last post by:
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...
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....
0
by: David | last post by:
- Are there any peculiarities with using curs.executemany(...) vs. multiple How many times are you calling execute vs a single executemany? The python call overhead will add up for thousands of...
1
by: samvb | last post by:
Hello Guys, I have a code that is workin fine from a click of a button. Is it possible to make that script execute automatically on 1st day of each month? Any suggestion wld b great. Thanks
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.