Problem with CGI
[1/9] from: ZikZak:wanadoo at: 25-Jan-2004 9:52
Hi,
I'm a beginner and I don't understand why I can not obtain some informations.
If I try to : mold system/options/cgi/query-string then the system doesn't give to me
the informations.
Why ?
Regards
--
ZikZak
REBOL/Core 2.5.6.4.2
Copyright 1997-2003 REBOL Technologies
REBOL is a Trademark of REBOL Technologies
All rights reserved.
Component: "REBOL Mezzanine Extensions" 1.1.2.1 (30-Nov-2002/13:47:03)
Component: "REBOL Internet Protocols" 1.59.2.15 (15-Nov-2002/5:20:31)
Finger protocol loaded
Whois protocol loaded
Daytime protocol loaded
SMTP protocol loaded
POP protocol loaded
IMAP protocol loaded
HTTP protocol loaded
FTP protocol loaded
NNTP protocol loaded
Component: "System Port" 1.1.2.5 (2-Jan-2003/1:37:25)
Script: "User Preferences" (8-Jan-2004/20:52:19+1:00)
>> mold system/options/cgi/query-string
== "none"
[2/9] from: carl:cybercraft at: 26-Jan-2004 20:47
On 25-Jan-04, ZikZak wrote:
> Hi,
> I'm a beginner and I don't understand why I can not obtain some
> informations. If I try to : mold system/options/cgi/query-string
> then the system doesn't give to me the informations.
> Why ?
Because there's none to give. (When REBOL is first launched, as in
your example below.) Query-strings are used on servers to catch the
information added to the end of URLs, such as...
http://www.google.com/search?q=rebol
There, the "q=rebol" after the "?" is the query-string. If the Google
website was using REBOL, "search" would be the script-name and each
time it was run when someone did a search
system/options/cgi/query-string would be loaded with what follows the
?
.
So, as far as I know, (I could be wrong - I'm no CGI expert),
query-strings are only useful when REBOL is running on a server.
If however you knew all that, are running REBOL on a server and still
are having problems, then a fuller explanation of your problem is
probably needed.
Carl Read.
> Regards
> --
<<quoted lines omitted: 18>>
> == "none"
>>>
--
Carl Read
[3/9] from: petr:krenzelok:trz:cz at: 25-Jan-2004 11:48
ZikZak wrote:
>Hi,
>
>I'm a beginner and I don't understand why I can not obtain some informations.
>If I try to : mold system/options/cgi/query-string then the system doesn't give to me
the informations.
>
>Why ?
>
system/options/cgi is object, which is being given data only if rebol is
run in cgi mode, so - do you run your rebol session using -c option?
#!/path/to/rebol/rebol -c
REBOL []
your script here ... don't forget to print following two lines first:
print "Content-Type: text/html"
print newline
btw: what OS and what web server do you use?
-pekr-
[4/9] from: ZikZak:wanadoo at: 25-Jan-2004 12:36
Le Sun, 25 Jan 2004 11:48:20 +0100
Petr Krenzelok <[petr--krenzelok--trz--cz]> a =E9crit :
||system/options/cgi is object, which is being given data only if rebol
|is |run in cgi mode, so - do you run your rebol session using -c
|option?|
||#!/path/to/rebol/rebol -c
||
||REBOL []
||
||your script here ... don't forget to print following two lines first:
||
||print "Content-Type: text/html"
||print newline
||
||btw: what OS and what web server do you use?
||
||
||-pekr-
Ok,
Here are the informations you need :
OS : GNU/Linux
Server : THY 0.7.1
Rebol : Core
My CGI (send.cgi) :
#!rebol -cs
rebol [title: "EMail"]
print "content-type: text/html^/"
data: system/options/cgi/query-string
cgi: make object! decode-cgi data
print [<HTML><BODY><h1>Email Status<h1><hr><P>]
failed: error? try [send to-email cgi/email cgi/message]
print either failed [
{the email could not be sent.}
][
[{the email to} cgi/email {was sent.}]
]
print {</BODY></HTML>}
==========================
======
My html form (email.html) :
<html>
<body>
<form action="http://127.0.0.1/cgi/send.cgi" method="get">
<h1>CGI EMAILER</h1><hr>
Enter your email address:<P>
<input type="text" name="email" size="30"><P>
<textarea name="message" rows="7" cols ="35">
Enter your message.
</textarea><P>
<input type="submit" value="Submit">
</form>
==========================
========
Do you need more informations ?
Regards
--
ZikZak
[5/9] from: ammon:addept:ws at: 25-Jan-2004 4:45
You got exactly what you were looking for. The molded value of
system/options/cgi/query-string from a fresh console is "none" If you would
like to know what the query string looks like try uploading a script to your
server that looks something like:
#!/path-to-rebol/rebol -cs
print "Content-Type: text/html^/" ;-- Required Page Header
print [<html><body><h2>"Probing query-string..."</h2>]
probe system/options/cgi/query-string
print [</body></html>]
A useful resource is www.rebol.org try searching for CGI and you will find
many usefull examples and tools.
HTH
~~Ammon ;->
[6/9] from: ZikZak:wanadoo at: 25-Jan-2004 13:09
||A useful resource is www.rebol.org try searching for CGI and you will
|find|many usefull examples and tools.
||
||HTH
||~~Ammon ;->
unfortunately this is an example I tried to use.
When I submit my form, my server returns an error page displaying this message :
** Script Error: Email has no value ** Near: Email Status
I can not figure out this message because I entered the Email value, my URL is : http://127.0.0.1/cgi/send.cgi?email=zikzak%40wanadoo.fr&message=Enter+your+message.%0D%0A
Quite strange for a beginner like me :-(
--
ZikZak<
[7/9] from: ammon:addept:ws at: 25-Jan-2004 5:29
Ok, what you are seeing here is that PRINT will try to obtain the value of a
WORD! (datatype) within a block. the simple fix for the error you are seeing
is to enclose the words "Email Status" in quotes thus making it a STRING!
instead of a word. This should work...
#!rebol -cs
rebol [title: "EMail"]
print "content-type: text/html^/"
data: system/options/cgi/query-string
cgi: make object! decode-cgi data
print [<HTML><BODY><h1>"Email Status"<h1><hr><P>]
failed: error? try [send to-email cgi/email cgi/message]
print either failed [
{the email could not be sent.}
][
[{the email to} cgi/email {was sent.}]
]
print {</BODY></HTML>}
HTH
~~Ammon ;->
----- Original Message -----
From: "ZikZak" <[ZikZak--wanadoo--fr]>
To: <[rebol-list--rebol--com]>
Sent: Sunday, January 25, 2004 5:09 AM
Subject: [REBOL] Re: Problem with CGI
> ||A useful resource is www.rebol.org try searching for CGI and you will
> |find|many usefull examples and tools.
<<quoted lines omitted: 3>>
> unfortunately this is an example I tried to use.
> When I submit my form, my server returns an error page displaying this
message :
> ** Script Error: Email has no value ** Near: Email Status
>
> I can not figure out this message because I entered the Email value, my
URL is :
http://127.0.0.1/cgi/send.cgi?email=zikzak%40wanadoo.fr&message=Enter+your+message.%0D%0A
[8/9] from: ZikZak::wanadoo::fr at: 25-Jan-2004 14:10
Le Sun, 25 Jan 2004 05:29:04 -0700
Ammon Johnson
<[ammon--addept--ws]> a =E9crit :
||
||Ok, what you are seeing here is that PRINT will try to obtain the
|value of a|WORD! (datatype) within a block. the simple fix for the
|error you are seeing|is to enclose the words "Email Status" in quotes
|thus making it a STRING!|instead of a word. This should work...
||
||#!rebol -cs
||
||rebol [title: "EMail"]
||
||print "content-type: text/html^/"
||
||data: system/options/cgi/query-string
||
||cgi: make object! decode-cgi data
||
||print [<HTML><BODY><h1>"Email Status"<h1><hr><P>]
Thank you, it works now.
quotes in the HTML code is strange, but I will take care of this kind of problem for
my next try.
--
ZikZak
[9/9] from: g:santilli:tiscalinet:it at: 25-Jan-2004 16:47
Hi ZikZak,
On Sunday, January 25, 2004, 2:10:24 PM, you wrote:
Z> Thank you, it works now.
Z> quotes in the HTML code is strange, but I will take care of
Z> this kind of problem for my next try.
That's because that is not HTML code, but REBOL code. If you quote
it, as one big string, you don't have this problem.
print {<HTML><BODY><h1>Email Status<h1><hr><P>}
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted