Following the advice here I can get a shell script in JavaScript that runs under node.js and prints a bit of hello world html:
test.cgi
-------
#!/usr/local/bin/node
console.log("Content-Type: text/html; charset=utf-8\n");
console.log("<html><body><h1>hello node.js world</h1></body></html>");
-------
And running it:
$ ./test.cgi
Content-Type: text/html; charset=utf-8
<html><body><h1>hello node.js world</h1></body></html>
It also works as expected in Apache and displays the expected HTML in the browser.
Now on to CoffeeScript (note the lovely triple-quoted here docs, Python-style):
ctest.cgi
-------
#!/usr/bin/env coffee
console.log("Content-Type: text/html; charset=utf-8\n");
console.log('''<html><body><h1>hello CoffeeScript world
</h1></body></html>''');
-------
This works when run locally:
$ ./ctest.cgi
Content-Type: text/html; charset=utf-8
<html><body><h1>hello CoffeeScript world
</h1></body></html>
But not in Apache:
Internal Server Error
Why doesn't this work?