Thanks, Jeff, for illustrating just how flexible and multi-facetted REBOL
really is
Compared to your example I can see how uneconomical my attempt was. The
timeout check was required, though, on a particular site prone to long
loading times - but I'm beginning to see how the check could be done more
eloquently. Much appreciated.
REBOL ROCKS!
-andre

ps
sorry, i seem to have messed the thread heading! 

>> 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

Reply via email to