Re: program with a timer
by davorg (Chancellor) on Jan 12, 2001 at 15:03 UTC
|
That doesn't sound like a CGI program to me.
I think that you need a Perl script which uses LWP to
grab the data from the web page and puts it in the database
using DBI/DBD. You'd then set up a cron job to
run your script periodically.
No CGI there at all.
--
<http://www.dave.org.uk>
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
| [reply] |
|
$five_mins = 300;
while(not $exit_condition) {
# Run LWP code here
sleep($five_mins);
}
| [reply] [d/l] |
|
On WINNT you can use their AT command to schedule
programs to run. I've used it for automating cron-type jobs and it works reasonably well.
Simply type
at/?
in your DOS/command window
to get more information.
Mick | [reply] [d/l] |
|
Re: program with a timer
by zigster (Hermit) on Jan 12, 2001 at 15:11 UTC
|
CGI is specifically a user orientated program, it runs only when the user requests a specific page. I am not sure what you are trying to do. My guess is one of two things:
- You are trying to suck data from the web to a local database for offline viewing (Quote: Retrieve the stock quotes from a web page and form a database) If you want to do this you have a few alternatives, take a look at HTTP client in perl a recient discussion that describes how to do this. You could also have a look at wget, a stand alone application. You will find wget at freshmeat
- You are trying to provide a web page that refreshes itself to show the latest information take a look at netscapes page on dynamic documentation here specifically it talks about server push and client pull methods for dynamic web content. The example it gives quote:
The general idea is that browsers have always been driven by user input. You click on a link or an icon or an image and some data comes to you. As soon as people saw they could do that, they wanted to give a server the ability to push new data down to the browser. (An obvious example is a stock trader who wants to see new quote data every 5 minutes.) Up until now, that hasn't been possible.
I hope this helps, if it does not then post some more details and I will see if I can help further.
--
Zigster | [reply] |
Re: program with a timer
by lzcd (Pilgrim) on Jan 12, 2001 at 15:10 UTC
|
In addition to investigating the LWP module from CPAN you also may wish to check out the perl command 'sleep'.
eg.
while (1==1) { # Loop forever
sleep 60*10; # do nothing for 10 minutes
# <- insert LWP web page stuff here ->
{
Update:Fell for the old 'lets switch equality for assigment' trick of 1=1 instead of 1==1. | [reply] [d/l] |
|
Can't modify constant item in scalar assignment at ./test.pl line 1, n
+ear "1) "
Did you mean just
while (1) {
--
<http://www.dave.org.uk>
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
| [reply] [d/l] [select] |
|
Thanks for spotting my typo.
I suppose your variation is just as good but TMTOWTDI stikes again with whats familiar for me.
| [reply] |
Re: program with a timer
by sutch (Curate) on Jan 12, 2001 at 23:45 UTC
|
An alternative to cron or NT's AT is to use your CGI program to retrieve the stock quotes when they have passed their "freshness" time. I've used this method to minimize requests to external hosts:
- maintain a database of stock symbols, quotes, and the last time retrieved.
- on each GGI request for a quote, retrieve the quote from the database. If it is not available or the last time retrieved is older than the max freshness time (say, five minutes), grab the quote from the external host and update the database.
This will ensure that application supplies the latest quotes (within five minutes) while avoiding unnecessary requests for quotes. | [reply] |
Re: program with a timer
by OzzyOsbourne (Chaplain) on Jan 12, 2001 at 19:31 UTC
|
The program would have to be consistently running (as a service maybe?) to execute at various times. Why not use a scheduler in your operating system such as the windows AT command to kick off your program?
-OzzyOsbourne
| [reply] |
Re: program with a timer
by tune (Curate) on Jan 13, 2001 at 03:41 UTC
|
| [reply] |