Hi Donal,

This has come up before, even in my own early use of REBOL.  Check the use
of 'either and a simple test case, and you can see better what's happening
in your script:

>> ? either
If condition is TRUE, evaluates the first block, else evaluates the second.
Arguments:
    condition --
    true-block --  (block)
    false-block --  (block)

ok, so what is the condition?  In your case, you're doing 'either on a
string returned as a result of reading the URL.  ANYTHING that is returned
by that URL (even a "page does not exist" message from the server when it
detects attempt to read non-existent page) will get put in that string 'page.

Let's see how 'either behaves with two types of strings:

>> a: none
== none
>> either a [print "true"] [print "false"]
false
>> a: "test"
== "test"
>> either a [print "true"] [print "false"]
true

So, unless the string read ('page in your case) is 'none, then 'either will
see a TRUE condition.

The same will happen if you try to use 'exists? on a non-existent page with
a web server that intercepts such failed attempts.  However, if  the server
truly returns a "404 error" then things work as exected:

>> exists? http://www.theskillstore.com/nonexistentpage.txt
== false

This is probably what you'd like to use (with an either ahead of it).

To see what actually got return, look at this:

>> page: read http://www.theskillstore.com/nonexistentpage.txt
** User Error: Error.  Target url:
http://www.theskillstore.com/nonexistentpage.t
xt could not be retrieved.  Server response: HTTP/1.1 404 Object Not Found.
** Where: page: read http://www.theskillstore.com/nonexistentpage.txt

>> print page
Date: Fri, 12 Nov 1999 12:59:05 GMT
Server: Apache/1.2.4
Location: http://www.PortONE.com/portone/error.html
Connection: close
Content-Type: text/html

Again, a test on "either page" doesn't do what you desire; but 'exists? does.

>> either page [print "true"] [print "false"]
true

>> either exists? http://www.theskillstore.com/nonexistentpage.txt [print
"true"] [print "false"]
false

Hope this helps.

To answer the second question, add this to the beginning of your script:

secure none


Russ

-----
At 12:26 PM 11/12/99 +0000, you wrote:
>Hi all,
>
>maybe a silly question, but I've written a small
>script to try and detect if my webpage is up and
>running every hour.
>
>page: read http://www.theskillstore.com
>either page[send [EMAIL PROTECTED] "http://www.theskillstore.com is up"]
>[send [EMAIL PROTECTED] "http://www.theskillstore.com is down"]
>
>I'm running it on NT and if it fails to read the page
>the script exits with
>
>** Access Error: Cannot connect to http://www.theskillstore.com
>
>is there a way around this ???
>
>also is there a way to set secure to none, and not get the 
>dialogue box asking to lower permissions ??
>
>Anyway good luck with REBOL it's a great tool.
>
>Donal
>
>"it's all fun and games until someone uses an ie browser"
>
>Donal Greene,
>Webmaster,
>Educational Multimedia Corporation (Ireland)
>EMG House
>Deansgrange
>Co. Dublin
>Tel:  +353 1 289 9000 extension 302
>Fax: +353 1 289 9150
>
>
>
>

Reply via email to