Hello [EMAIL PROTECTED],
Comments below...
On 18-Jul-00, [EMAIL PROTECTED] wrote:
> Would it be possible to use the REBOL console via CGI? As follows:
>
>
> 1. Enter commands in to a text area within a Web form. The text area is
> given the name "rebol_input"
>
> <TEXTAREA NAME="rebol_input" ROWS="10" COLS="80"></TEXTAREA>
>
>
> 2. Hit <ENTER> and the contents of the query_string, containing a single
> string value for a single word called "rebol_input", is sent to a script.
>
>
> 3. The script decodes the CGI and creates the value 'cgi-input/rebol_input
> containing the input string for the console
>
> cgi-input: make object! decode-cgi system/options/cgi/query-string
>
> 4. The script executes 'cgi-input/rebol_input sending the command to the
> console.
>
> do cgi-input/rebol_input
>
> 5. Now here is where I'm stuck. How can I grab the result from the binary so
> that I can print it to the browser?
I'm not sure what you mean by "the binary", however if you mean the rebol binary, try
the attached script.
It's not quite what you asked for, but you might get some ideas.
BTW.
The script was tested on Apache 1.3.12 (Amiga) and IE (Win98), please let me know if
it works. You probably want to change the first line of the script to match your REBOL
location and name...
Best regards
Thomas Jensen
#! /rebol/rebol.core -c
REBOL [
Title: "CGI-test"
Date: 18-Jul-2000
Name: 'cgi-test
Version: 0.1
File: %cgi-test.r
Author: "Thomas Jensen"
EMail: [EMAIL PROTECTED]
Language: 'English
Charset: 'ANSI
Tabs: 4
]
print "content-type: text/html"
print ""
secure quit
cgi-args: make object! decode-cgi rebol/options/cgi/query-string
command: either none? in cgi-args 'expr [
""
] [
cgi-args/expr
]
prin rejoin [
{<html>
<head>
<title>REBOL</title>
</head>
<body>
<p align="center">
<form action="} rebol/options/cgi/script-name {" method="get">
<big> enter rebol expression </big> <br>
<input type="text" name="expr" size="50" value="} command {">
<input type="submit" name="action" value="do">
</form>
<table border="1" bgcolor="ffffff">
<tr>
<td>
<pre>}
]
either error? err: try [
res: do command
none
] [
err: disarm err
; don't warn on error 301 (*mostly* it's "res needs a value")
; should be handled better
if not err/code = 301 [
print ["ERROR: " mold err]
]
] [
print rejoin ["== " mold res]
]
print rejoin [
{</pre>
</td>
</tr>
</table>
</p>
<pre>
</body>
</html>}]