cgi example

Edwin Haskell ehaskell at selfcorp.com
Fri Jul 5 00:04:01 EDT 2002


On Tuesday, July 2, 2002, at 04:04 AM, use-revolution-
request at lists.runrev.com wrote:

>> #!/Library/WebServer/CGI-Executables/Darwin
>>
>> on startUp
>>   put "Hello World!" into tresponse
>>   put "Content-Type: text/html" & cr
>>   put "Content-Length:" & the length of tresponse & cr & cr
>>   put tresponse
>> end startUp
>>
>
> This is an excellent first start.
>
> Have you figured out how to collect all the client browser data from
> the incoming connection? Have you figured out how to data sent via
> POST or GET?


Here are some scripts I got from Andu Novak that might address this. So 
far I'm still stuck with a header error.
#!mc

on startUp
read from stdin until empty #read the POST/GET request from Apache
#do whatever you want with the content and put it in a variable(var1)
put "Content-Type: text/html" & crlf
put "Content-Length: " & length(var1) & crlf & crlf
put var1
end startUp

Remember, the toughest thing with cgis is debugging since you can only 
do it in terminal and you hardly get any input as to where the problems 
might be. Best way is to test the script in a stack (and debug it) and 
then copy/paste in the cgi file.
bellow is the typical echo.cgi script which should help you testing the 
functionality:

#!mc

on startup
read from stdin until empty
put it into tBuffer
# loop over all of the global variables, getting name and value
  repeat for each item i in the globals
   put i & "=" & value(i)  & cr after tBuffer
end repeat
replace cr with "<BR>" in tBuffer
put "Content-Length:" && the length of tBuffer & crlf
put "Content-Type: text/html" & crlf & crlf
put  tBuffer
end startup




More information about the use-livecode mailing list