>>-----original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>>Subject: [REBOL] Need a Script Re:(2)
>>
>>
>>Russ thanks for the help. I am trying to make a script to check a site
>>every xx:xx minutes and see if a specific word on a page exists. if
>>not send me email... and do this forever...
>>
>>Regards,
>>Philip M. McDonnell
>>-----------------------
>>
-------------------snip--------------------------------------------
>
> REBOL [
> Title: "WebSiteCheck"
> File: %webchk.r
> Date: 22-Oct-1999
> Purpose: {Check a set of sites every 5 minutes
> & mail an error response only once}
> Author: "Andre Venter"
> ]
> secure none
>
> sites: [
> "Site 1" http//www.site1.com "1"
> "Site 2" http//www.site2.com "1"
> "Page2" http//www.site1.com/page2.htm "1"
> ]
>
> while [ true ][
> foreach [name url status] sites [
> start: fourth now
> either error? try [read url][
> if status = "1" [
> message: reform ["Rebol Alert:" name "is down!"]
> send [EMAIL PROTECTED] message
> change status "0"]
> ]
> [change status "1"]
> stop: fourth now
> if stop - start >= 0:00:45 [
> if status = "1" [
> message: reform ["Rebol Alert:" name "timed out!"]
> send [EMAIL PROTECTED] message ;
> ]
> ]
> ]
> print reform [fourth now "Pausing for 5 min"]
> wait 0:05:00 ; ------------ //change to suite your needs
> ]
Another approach:
sites: [
http://www.worldrps.com
http://www.theonion.com
http://www.rebol.org
http://www.doesnotexist.com
http://www.neitherdoesthis.com
]
total-no-go: copy []
forever [
no-go: copy []
foreach site sites [
all [not exists? site append no-go site]
]
if not empty? no-go: difference no-go total-no-go [
send [EMAIL PROTECTED] reform ["These sites down:" no-go]
]
total-no-go: union total-no-go no-go
wait 00:05:00
]
EXISTS? works for urls. The UNION and DIFERENCE functions let you
see pretty quickly when something new has entered a set of items, in
this case the set of missing sites. Like Andre's code, the above will
only send mail the first time a site goes down (but the above code
doesn't deal with time out errors, as Andre's does (-:). Using
DIFFERENCE you can also then restrict further checking of urls to only
those sites you haven't found to be down previously.
(ie: sites: difference sites total-no-go).
There's so many ways to do things in REBOL. It's just t00 k00l! :)
-jeff