[Metacard] CGI under OS X via Darwin Success...
Richard MacLemale
rmaclemale at earthlink.net
Sat Nov 24 16:26:01 EST 2001
Thanks to all who helped both on list and off. The MetaCard mailing list
rocks almost as much as MetaCard itself...
I've got the Darwin engine handling MetaCard scripts via CGI working very
well now. I still have a lot to learn, but "the basics" are a done deal.
So I thought I'd share what I learned. I'm eventually going to put together
a web page on using MetaCard's Darwin engine to do CGI on OS X, but in the
meantime, for anyone else attempting this, here's some roadblocks that I had
to jump...
1. Installing the darwin engine is way simple. I was trying to get all
fancy, but in reality all you have to do is download the darwin engine, the
tools and home stacks, and double-click them. Stuffit will uncompress and
unpack them. Then just put them in the following folder:
/Library/WebServer/CGI-Executables
Also get a copy of the echo.mt file and put THAT in the same folder.
2. Obviously make sure Apache is running by typing in:
http://(your IP address)/
And you should get a default Apache page.
3. I had to edit the httpd.conf file. For some reason, once I got echo.mt
working, it only worked every OTHER time I clicked on it. I uncommented the
following line in httpd.conf:
AddHandler cgi-script .cgi
After I did that, echo.mt worked every time. Why? I dunno. Speaking of
echo.mt, mine was returning everything in one line to my browser, instead of
in separate lines like the one on the metacard site does. I changed
put "Content-Type: text/text" & cr
to
put "Content-Type: text/html" & cr
and now it works perfectly.
4. BB Edit Lite for OS X is a MUST HAVE tool. And it's free. Not only
will it allow you to find hidden files, it will also allow you to edit files
like httpd.conf and save them with UNIX line breaks (you have to choose Save
As.) If you save a UNIX file without UNIX line breaks, it will... break.
5. Permissions are critical. Obviously you have to give mc the ability to
execute.
I couldn't get a script to create a new text file and write to it, or to
open an existing text file and read or write to it. Then I remembered (duh)
permissions. As long as the file exists, and the permissions are set
correctly, a metacard script can open a text file and write to it or read
from it. So cool.
6. If you don't know some basic UNIX, you can't do this cool stuff. Good
thing I'm learning UNIX...
This unlocks the candy store for me. One thought goes through my mind,
though... Suppose an individual were to download the darwin engine, and the
home and tools stacks... And suppose they install them and write some neato
mt scripts for their OS X based web site. Scott says that the script limit
does not apply to the Darwin engine when running in non-GUI mode. Doesn't
this mean that anyone who wanted to could do CGI stuff with MetaCard for
free? If this is intentional, then it should be, well, advertised. Maybe
as a way of getting some UNIX or Mac OS X people in the door. MetaTalk is a
kabillion times easier to learn than Perl...
Just thinkin' out loud.
:)
Richard MacLemale
Instructional Technology Specialist
James W. Mitchell High School
More information about the metacard
mailing list