in reply to getting a cgi script working

There exist a number of good resources books, and such, that can answer this question much better for you than I can, but here are a couple simple rules to keep in mind.
  1. make sure that the script is executable.
  2. always start out your scripts with a "Content-type: <something>\n\n" line.
  3. If a script runs in a command-line window, then it should also work as a cgi.