HyperActive CGI Tutorial - address stack example?

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jpatten
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 45
Joined: Tue May 06, 2008 11:24 pm

HyperActive CGI Tutorial - address stack example?

Post by jpatten » Fri Jun 13, 2008 12:17 am

Hi All...

I'm going through and taking a closer look at the cgi capabilities of rev. I'm using the HyperActiveSoftware tutorial.

Everything works great just as described, until I get to the part about using the stacks as libraries with CGIs.

I'm getting the following error:

The server encountered an internal error and was unable to complete your request.

Error message:
Premature end of script headers: addressSearch.cgi

If you think this is a server error, please contact the webmaster.
Error 500


I have followed the tutorial multiple times and I'm still not successful.

This is running on and OS X Server (Intel) running 10.5.3.

Any suggestions for what I might try?

Thank you!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Post by FourthWorld » Fri Jun 13, 2008 3:27 pm

It may be that the script file was written on a Mac or PC, and doesn't have UNIX line endings.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Fri Jun 13, 2008 4:06 pm

Make sure to close the stack, or include "quit" as the last line of your cgi script. Newer Rev CGI engines will not terminate properly if stacks are still open when your script finishes, and apache will terminate it forcefully, resulting in a 400 error.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

jpatten
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 45
Joined: Tue May 06, 2008 11:24 pm

Post by jpatten » Fri Jun 13, 2008 5:51 pm

A little closer but still not there :(

The Rev CGIs work with the first three examples on the HyperActiveSW.

However, when trying to use the example with the stack addressbook, it's still a no go.

I know the first part of the addressSearch.cgi is running, becomes the browser complains about not finding the data stack.

I thought I may have figured it out, I remembered with SuperCard we had to give the full address, not the web address, to the stack. But that wasn't it either.

The cgi script I'm using is by Jacqueline <http://www.hyperactivesw.com/cgitutorial/scripts3.html>


#!revolution

on startup
put $QUERY_STRING into theTerms
put "" into buffer
put "addresses.rev" into theStack
if theTerms = "" then
put "No query submitted." after buffer
else if there is no stack theStack then
put "Data stack cannot be found." after buffer
else
start using stack theStack
set the defaultstack to theStack
put 0 into theCt
put theTerms into theTermsArray
split theTermsArray by "&" and "="
put urlDecode(theTermsArray["terms"]) into theSearchWords
put urlDecode(theTermsArray["searchScope"]) into theScope
unmark all cds

if theScope = "byfield" then
delete char 1 to offset("&Fields",theTerms) of theTerms
replace "Fields=" with empty in theTerms
replace "&" with comma in theTerms
put theTerms into theFldList
repeat for each item i in theFldList
mark cds by finding theSearchWords in fld i
end repeat
else -- find in all flds
mark cds by finding theSearchWords
end if
repeat with x = 1 to the number of marked cds
put fld "name" of marked cd x & "<br>" & cr after buffer
put fld "address" of marked cd x & "<br>" & cr after buffer
put fld "city" of marked cd x && \
fld "state" of marked cd x && \
fld "zip" of marked cd x & "<br>" & cr after buffer
put fld "phone" of marked cd x & "<p>" & cr after buffer
add 1 to theCt
end repeat
stop using stack theStack
end if

put "<h3>Results for " &quote& theSearchWords &quote& colon \
& "</h3>"& theCt && "found" && "<p>" before buffer
put "</body> </html>" after buffer

put "Content-Type: text/html" & cr & cr
put buffer
--quit >also tried adding the quit at the end as was suggested, but did not seem to make a difference in the result
end startup

Other ideas?

Thank you!

jpatten
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 45
Joined: Tue May 06, 2008 11:24 pm

Post by jpatten » Fri Jun 13, 2008 7:25 pm

Solution!

I had been opening up the addresses.rev stack in the latest version of Rev and then saving it again.

However, I was not saving as a LEGACY REVOLUTION STACK format!

I new it had to be something simple....as it seems it usually is :wink:

Thanks!

Post Reply

Return to “CGIs and the Server”