title: "CGI Remote Console"
    date: 26-sep-2009
    file: %remote-console.r
    purpose: {
       Allows you to type REBOL code into an HTML text area, and have
       that code execute directly on your web server.  The results of the 
       code are then displayed in your browser.  This essentially functions
       as a remote console for the REBOL interpreter on your server.  You
       can use it to run REBOL code, or to call shell programs directly on
       your web site.  DO NOT run this on your web server if you're 
       concerned at all about security!
       Taken from the tutorial at

#! /home/path/public_html/rebol/rebol276 -cs
REBOL [Title: "REBOL CGI Console"]
print "content-type: text/html^/"
print {Console}
selection: decode-cgi system/options/cgi/query-string

; If no data has been submitted, print form to request user/pass:

if ((selection/2 = none) or (selection/4 = none)) [
    print {
        W A R N I N G  -  Private Server, Login Required:



} quit ] ; If code has been submitted, print the output: qq: [ print {

} ] if selection/2 = "command-submitted" [ write %commands.txt join "REBOL[]^/" selection/4 ; The "call" function requires REBOL version 2.76: call/output/error "/home/path/public_html/rebol/rebol276 -qs commands.txt" %conso.txt %conse.txt print rejoin [ {

} {
        read %conso.txt

} {Errors:

} read %conse.txt {
} ] do qq quit ] ; Otherwise, check submitted user/pass, then print form for code entry: username: selection/2 password: selection/4 either (username = "user") and (password = "pass") [ ; if user/pass is ok, go on ][ print "Incorrect Username/Password." quit ] do qq