Lessons by Jon

Saving as CGI

I only know how to do this from within the Script Editor application. The steps will probably differ inside other script editing applications. The general thing to remember is that the script must be saved as a run-only application with the splash screen turned off and set to stay open. If the splash screen comes open it will interfere with AppleEvent processing. If the application doesn't stay open, it will likely quit before the AppleEvent is received. This is because there is a slight delay between when MacHTTP launches the application and when the AppleEvent is sent to the application. Since most of your CGI applications don't have significant processing outside of the AppleEvent-handling loop, the application will quit almost immediately.

These are the steps to follow to save an AppleScript script as a CGI application:

  1. Click on the "Check Syntax" button so that references to applications are resolved and any errors are tracked down.
  2. Select "Save" from the "File" menu if any changes have been made.
  3. Select "Save as run-only..." from the "File" menu. This will create an application which cannot be edited, so be sure to keep the source code!
  4. Select a name for the application that ends in ".cgi". This is necessary so MacHTTP will know to treat it as a CGI application. Select the folder you want to save the application in.
  5. Click on "Save" to save the application.

Earlier I talked about the difference between synchronous and asynchronous handling of CGI applications. If you want to use asynchronous handling, then you should change step (4) so that the filename ends in ".acgi". All of the scripts I have provided (excepting Script1.txt) can be used as either ".cgi" or ".acgi" applications by merely changing the filename. This is not true of all CGI applications, so beware.


Jon Wiederspan
Last Edited: November 25, 1994