0

Hi all. Here's my situation and how I'm solving it. Please let me know if my methods look good or if there is a better way of doing it.

A local business around here has a drawing each day where they pick some customers' names to win something. The winners' names are posted on a web page each day. I wanted to automate getting the results, specifically if my name is on the list.

I wrote up a PHP script that does the following: First it fetches the content of the page using curl_exec. Then it searches those results using stristr for the name(s) that I'm interested in. If it finds them, it appends the name(s) to a string of winners and sets a flag to true. After checking for the names, if the flag is true, I use mail to send the results, including the names, to my email. I have a cron job set up to wget the page with the script every morning.


Is that pretty much a reasonable way of doing it, or would there be a better way?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by donaldw
1

Sounds good - I use a similar system to send me a message when a particular radio station plays the same song twice in one day (first caller gets $1,000). The songs are posted on their web site.

Anyway, back to what you're doing: You could improve the cron side of things. Instead of using cron to call wget, which calls the PHP page (via a Web server), why not modify your PHP file like so:

#!/usr/bin/php
<?php

// your PHP code here

?>

Ensure the file has execute permissions (chmod 700 will work becase that gives you permissions to read, write and execute).

Then just have cron call that file instead of wget. (That file is effectively an executable script).

Note: You may need to change /usr/bin/php to match the path of wherever PHP happens to be installed on your server.

0

That's a good idea. Plus, then I could eliminate my other cron job of rm-ing the file that I fetched.

Ever won that thousand bucks?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.