Web form - Applescript app - do shell script - stdout to web browser?

Just so everyone knows, I am aware that ACGI Dispatcher will do this for me. If I wasn’t so obsessed with figuring it out I would just drop the $35 and buy it, but I have become Ahab. The solution my white whale.

Here’s where I am at:

I have modified Apples Webpage Helper application to receive form variables from my test form and parse through them, look up a user in FM Pro, create a basic HTML page with the variables in it, and then?

You see below a working script that will simply echo back the HTML page from the variables, it is the last step in my process meant to create (or serve if you will) a new webpage for the end user. I have tried to use ‘echo’ and ‘printf’ and while neither of them give me any errors they also do not give me a webpage in my browser. Maybe I am thinking of the process all wrong - in my mind I see the form in the browser as the starting point of a path and as long as the process remains unbroken (ie: no script errors, power failures, etc.) the path will loop around and “echo” the webpage back to the originating browser. right now everything works EXACTLY as I envision it - except for the webpage going to the browser bit. It seems to echo or printf into the void.

Maybe this is an Apache configuration issue, maybe a Unix one, it may even be a problem with my apple scripting (though I don’t think so). If anyone here is a Unix or Apache aficionado, do you have any ideas I can try? Did I need that #! /bin/sh/ thing before the Content-type: text/html? Does the application have to be in the CGI-Executables folder to run right (it is, but does it have to be)?

set lHTMLTitle to "Thank you"
set lPageHeader to "It has been determined that the following queue would be the fastest to process your job -"
set lBodyCopy to "WebDAV address / FTP Address / User Name / Inbox" -- Get this info from FM Pro at runtime
set lHTMLReply to ("Content-type: text/html" & return & return & "<HTML><HEAD>" & return & "<TITLE>" & lHTMLTitle & "</TITLE>" & return & "</HEAD><BODY>" & return & "<H1>" & lPageHeader & "</H1>" & return & return & lBodyCopy & return & "</BODY></HTML>") as text
-- Log the assignment to the Main server DB

do shell script ("echo \"" & lHTMLReply & "\"") -- I have also tried 'printf' but can't seem to get 'cat' to work

If this bears no fruit I will indeed be forced to buy the ACGI Dispatcher application, but it will be with the bitter taste of defeat in my mouth. :stuck_out_tongue:

Well, no help here AND James Sentman apparently doesn’t respond to his emails for help with ACGI Dispatcher… Quite the conundrum.

Work in progress:

Link in webpage running on my server as test

Placed in the /CGI-Executables/ directory

Placed in the /CGI-Executables/ directory

Applescript - myscript.scpt


set lTestVars to (do shell script "#!/bin/sh
echo \"$webvars\"") as text

if lTestVars ≠ "" then
	say (lTestVars as text) -- Testing only
	set lHTMLReply to ("echo Content-type: text/html
echo
echo \"<html><head><title>Hello Eric</title>\"
echo \"<h1>IT WORKED!</h1>\"
echo \"The variables were present<br>\"
echo \"</body></html>\"") as text
	
else
	say "There were no variables passed" -- Testing only
	set lHTMLReply to ("echo Content-type: text/html
echo
echo \"<html><head><title>Hello Eric</title>\"
echo \"<h1>Sorry, no variables</h1>\"
echo \"</body></html>\"") as text
end if

do shell script ("#!/bin/sh" & return & lHTMLReply as text)
end open

Note: Yes, I AM still working on this and so far I am receiving the variables from the wrapper but it fails at sending the HTML back to the browser. It might seem like I have made no progress on this but I think I am learning a lot the more I fail. I think I might just figure this out eventually.:confused: Once I have figured out how to send the html back the parsing of the variables received will be a piece of cake.