On 1/30/2000 at 10:42 PM [EMAIL PROTECTED] wrote:
{
Hi, I'm having trouble using REBOL for CGI scripts. What do I have to
do?
Also, how do I find out which version of Libc I'm running for Linux?
Thanks.
}
CGI scripts can be hard because there's not a lot of feedback. Here's
some basics, most of which you may already now, but we'll touch on
everything in case it helps. (I also need to get some FAQs together for
REBOL.ORG:-)
0. For Linux 4.x and prior I think you need Lib5c, for 5.x and and
later I think you need Lib6c.
1. You can usually just put the REBOL binary in your CGI-BIN directory,
which most ISP's set aside for running scripts.
2. The first line of your CGI script needs to be the path to your REBOL
binary. Sample scripts often say "#!path/to/rebol" here. This is from
the local server's viewpoint which is usually NOT the same as the Web
site URL. This can be confusing, since you call the script from your
Web form using one path, and then use a different path inside the
script. When you login via FTP or TELNET you can usually figure out
what the path to your CGI-BIN is. On my server it's
"/home2/husted/www/cgi-bin".
3. You usually need TELNET access to a Linux server to get the scripts
to run right. This is because Linux needs things to have the right
permissions set. For a script, you do this with a program called
"chmod". To set a script called "test.cgi" to run, you would enter a
command like "chmod 755 test.cgi" (without the quotes). If the script
uses a data file, you can mark it read/write with "chmod 666 test.dat".
To check your work enter "ls -o". The one other command you need to
know is "cd" to change the current directory. Also remember that Unix
systems are case-sensitive. TEST.CGI and test.cgi are two different
files. For more see http://bignosebird.com/unix.shtml and
http://hoohoo.ncsa.uiuc.edu/cgi/overview.html .
4. Most problems running CGI are either the path or the permissions.
Especially if everything else in the script works from the console.
(Hint: you can simulate simple CGI input just by assigning a string to
system/options/cgi/query-string .)
5. here's a simple script to test both CGI access and what variables
your scripts are sending over.
{
#!/path/to/rebol --cgi
REBOL[]
print {Content-Type: text/plain
hello world!
}
query: make object! decode-cgi-query either
system/options/cgi/request-method = "GET"
[system/options/cgi/query-string] [make string! input]
probe query
quit
}
The "query:" line will get wrapped by the mailer, but it is one line
follwed by "probe query" on the next line. This will decode whatever
variables you send over the same way, regardless of whether they were
sent by GET or POST. So it's a great item for your production scripts.
I'm also just finishing up a generic form-mailer if anyone would like
to see it. It's designed to send email from any form without
modification, using any of the standard header fields. I just have to
add spam-control and confirmation-page features.
HTH -Ted.