CGI and find

J. Landman Gay jacque at hyperactivesw.com
Tue Sep 2 12:16:02 EDT 2003


I wrote:

> Has anyone been able to get "find" to work in a cgi? I think I 
> remember someone said they could, but I have never been able to.

I'd like to pursue this some more (again; I've asked about it on the 
list before.) I just did some testing and am getting weird results.

Because I couldn't get "find" to work with a cgi, I had written a script 
that loops through all the fields of each card looking for a search 
term. The script creates an html document out of the results, which it 
places into the variable "buffer", and ends by writing a minimal header 
like this:

   put "Content-Type: text/html" & cr
   put "Content-Length:" && the length of buffer & cr & cr
   put buffer -- this contains the html text

This works fine. But it would be easier and quicker to use "find" to 
compile the search results. I wrote a "find" routine that works well in 
the IDE. Everything in this second script is the same as the first 
script, except that instead of looping with "offset" I use "find" to 
locate instances of the search term. I get the same search results and 
the script builds the same html document. I use the same header as above 
when outputting the results.

When I run this "find" script as a cgi, I get a "malformed header" error 
in the system log:

   malformed header from script. Bad header=0 0: 
/Library/WebServer/CGI-Executables/search.mt

Why would a header be "malformed" in the second case and not in the 
first? What difference would it make how the content was collected? 
Every other part of both scripts is identical.

What header should I use?

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list