![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| ffellico@inwind.it (Franco Fellico') wrote in message news:<d8b4dc5c.0308200554.196ac7c8@posting.google. com>... > > I need to prepare a progam (like a demon). It must stay always > sleeping and periodically it must watch a DB table; when it meet a > particular condition it must send a e-mail to someone. > > As you understand the program need to be started in my server (where I > have yhe MySql DB) an it don't need to be developed inside a HTML > page. > > Can someone suggest me how to write it outside HTML and how I can > start and stop it ? First of all, you don't need a daemon to do this. A "normal" script combined with scheduling will work just as well. To give you a more precise recommendation, however, I need to know three things: (1) can you run php in command line? (2) do you have root-level control over your production server, and, if not, do you have any other machine you control that has an "always-on" connection to the network where your production server is? and (3) what OS are you running on the machine you control? Cheers, NC | |||
| Advertisements |
| | #2 | ||
| Ok Nikolai. Thank you for your help. Here are the information you need. I will first check the program on my local LAN where I have all the autority on my Pc's and on my Linux server (here I have only a dial-up connection, but naturally during the tests I will be always connected). In the next future I would move the program on a outside unix-server always connected to Internet (at present I have not yet a contract with such a server) and I suppose that there I can't have root-level control and I can't have the autority to start a program from a command line (there I will have only space, PHP and MySQL). So, yet I am thinking that I must start the program from here and that in this case it's better to prepare a HTML page with PHP code inside to start the program there (this program to be started should be the one outside HTML page); I could see here the result of a correct start with a message on a HTML page. With another HTML page (again with PHP inside) should be possible to stop the program from here and receive a confirmation message. If you think that I am not wrong please give me some suggestion for my needs: - How prepare the PHP program outside a HTML page - How to start it from a code in a HTML page - How to stop it from a code in a HTML page - Finally how periodically wait in PHP some time before make the work A lot of thanks. Franco. nc@iname.com (Nikolai Chuvakhin) wrote in message news:<32d7a63c.0308201431.41e1c6a6@posting.google. com>... > ffellico@inwind.it (Franco Fellico') wrote in message > news:<d8b4dc5c.0308200554.196ac7c8@posting.google. com>... > > > > I need to prepare a progam (like a demon). It must stay always > > sleeping and periodically it must watch a DB table; when it meet a > > particular condition it must send a e-mail to someone. > > > > As you understand the program need to be started in my server (where I > > have yhe MySql DB) an it don't need to be developed inside a HTML > > page. > > > > Can someone suggest me how to write it outside HTML and how I can > > start and stop it ? > > First of all, you don't need a daemon to do this. A "normal" script > combined with scheduling will work just as well. > > To give you a more precise recommendation, however, I need to know > three things: (1) can you run php in command line? (2) do you have > root-level control over your production server, and, if not, do > you have any other machine you control that has an "always-on" > connection to the network where your production server is? and > (3) what OS are you running on the machine you control? > > Cheers, > NC | |||
| | #3 | ||
| ffellico@inwind.it (Franco Fellico') wrote in message news:<d8b4dc5c.0308202130.3dc21410@posting.google. com>... > > In the next future I would move the program on a outside unix-server > always connected to Internet (at present I have not yet a contract > with such a server) and I suppose that there I can't have root-level > control and I can't have the autority to start a program from a > command line (there I will have only space, PHP and MySQL). OK, so you don't have access to command line and root-level control of your production server. If so, here is what you need to do: 1. Write the script as you normally would, without worrying about the correct launch timing (simply assume that the timing is correct when writing the script). 2. Place that script on your production server. Let's assume that the script now resides at http://server.com/path/script.php 3. Now the question is, how do you schedule execution? Since you are saying you won't have root-level access, you can't use cron on the remote server. So you will have to use scheduling available elsewhere. If your LAN is connected to the Internet, you have two options: a. If you have a Linux machine on your LAN, place a one-line shell script (name doesn't matter) into cron.hourly, cron.daily, or cron.weekly directory (depending on how often you want your script run). Here is the line: wget http://server.com/path/script.php --quiet -O /dev/null b. If you have a Windows machine on your LAN, define a shortcut to http://server.com/path/script.php and then use Windows Scheduler to periodically run that shortcut. Basically, we are trying to separate functionality from scheduling. Functionality has to reside on the production server, but scheduling can live anywhere... Your script will execute on the production server, but execution will be triggered remotely by another machine. Hope this helps. Cheers, NC | |||
| | #4 | ||
| Again thanks Nikolai. I understand about everything but I am sorry because, as I said you, my LAN it's not continuously connected to Internet so I can't schedule the functionality from my LAN; so I will try to ask to a my friend that have a machine always connected to do this for me. Any way I have not clear the funcion of the statement: wget http://server.com/path/script.php --quiet -O /dev/null I watched "man wget" and I understand that it downolad the page, but when the page is downloaded with this command, will be also executed the PHP code inside it ? Greetings. Franco nc@iname.com (Nikolai Chuvakhin) wrote in message news:<32d7a63c.0308211349.270fbdb0@posting.google. com>... > ffellico@inwind.it (Franco Fellico') wrote in message > news:<d8b4dc5c.0308202130.3dc21410@posting.google. com>... > > > > In the next future I would move the program on a outside unix-server > > always connected to Internet (at present I have not yet a contract > > with such a server) and I suppose that there I can't have root-level > > control and I can't have the autority to start a program from a > > command line (there I will have only space, PHP and MySQL). > > OK, so you don't have access to command line and root-level control > of your production server. If so, here is what you need to do: > > 1. Write the script as you normally would, without worrying about > the correct launch timing (simply assume that the timing is > correct when writing the script). > > 2. Place that script on your production server. Let's assume > that the script now resides at http://server.com/path/script.php > > 3. Now the question is, how do you schedule execution? Since > you are saying you won't have root-level access, you can't > use cron on the remote server. So you will have to use > scheduling available elsewhere. If your LAN is connected to > the Internet, you have two options: > > a. If you have a Linux machine on your LAN, place a one-line > shell script (name doesn't matter) into cron.hourly, cron.daily, > or cron.weekly directory (depending on how often you want your > script run). Here is the line: > > wget http://server.com/path/script.php --quiet -O /dev/null > > b. If you have a Windows machine on your LAN, define a shortcut > to http://server.com/path/script.php and then use Windows > Scheduler to periodically run that shortcut. > > Basically, we are trying to separate functionality from scheduling. > Functionality has to reside on the production server, but scheduling > can live anywhere... Your script will execute on the production > server, but execution will be triggered remotely by another machine. > > Hope this helps. > > Cheers, > NC | |||
| | #5 | ||
| ffellico@inwind.it (Franco Fellico') wrote in message news:<d8b4dc5c.0308212114.4d7a0924@posting.google. com>... > > I understand about everything but I am sorry because, as I said you, > my LAN it's not continuously connected to Internet so I can't schedule > the functionality from my LAN; so I will try to ask to a my friend > that have a machine always connected to do this for me. Well, you have to schedule from somewhere... It doesn't really matter from where, as long as the scheduling machine doesn't go offline too often. > Any way I have not clear the funcion of the statement: > > wget http://server.com/path/script.php --quiet -O /dev/null > > I watched "man wget" and I understand that it downolad the page, but > when the page is downloaded with this command, will be also executed > the PHP code inside it ? Of course. The script will be executed just as if you called it from your browser. The "--quiet" option makes sure that wget doesn't output anything (no one will read it anyway), and the "-O /dev/null" option tells wget to send the results of the script's work to /dev/null, so you don't accumulate unnecessary HTML on your gard drive... Cheers, NC | |||
| | #6 | ||
| OK NIKOLAI. THANK YOU FOR YOUR KINDNESS. I REALIZED EVERYTHING AS YOUR SUGGESTIONS. IT WORK OK. NOW I MUST ONLY FIND A FRIEND WITH A PERSISTENT CONNECTION THAT COULD EXECUTE MY SCRIPT PERIODICALLY. GREETINGS FROM GAETA IN ITALY nc@iname.com (Nikolai Chuvakhin) wrote in message news:<32d7a63c.0308221117.1a3b8827@posting.google. com>... > ffellico@inwind.it (Franco Fellico') wrote in message > news:<d8b4dc5c.0308212114.4d7a0924@posting.google. com>... > > > > I understand about everything but I am sorry because, as I said you, > > my LAN it's not continuously connected to Internet so I can't schedule > > the functionality from my LAN; so I will try to ask to a my friend > > that have a machine always connected to do this for me. > > Well, you have to schedule from somewhere... It doesn't really > matter from where, as long as the scheduling machine doesn't go > offline too often. > > > Any way I have not clear the funcion of the statement: > > > > wget http://server.com/path/script.php --quiet -O /dev/null > > > > I watched "man wget" and I understand that it downolad the page, but > > when the page is downloaded with this command, will be also executed > > the PHP code inside it ? > > Of course. The script will be executed just as if you called > it from your browser. The "--quiet" option makes sure that wget > doesn't output anything (no one will read it anyway), and the > "-O /dev/null" option tells wget to send the results of the > script's work to /dev/null, so you don't accumulate unnecessary > HTML on your gard drive... > > Cheers, > NC | |||
| Featured Websites | ||||
|
![]() |
| Tags: html, outside, page, php, use |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can I use PHP outside a HTML page ? | shell | PHP | 0 | 07-01-2007 5:22 PM |
| Looking for a way to generate an HTML file download page... | Jay Vance | PHP | 6 | 07-01-2007 3:40 PM |
| How to pass data to HTML page without cookies? | Robert Oschler | PHP | 1 | 07-01-2007 3:37 PM |
| Where does PHP embedded in an HTML page execute? | rush | PHP | 0 | 07-01-2007 3:37 PM |
| page with no .html | olwen | HTML | 6 | 07-01-2007 1:57 PM |
| Featured Websites | ||||
|