Problem with cgi script


I’m trying to learn some cgi and I’m having a problem running a simple script that should email a form to me.

The form is here:

The cgi script is here:

A copy of the script is here:

When I actually try and fill out the form I get an Internal Server Error.
I’m hoping someone with a little more experience can tell me where I’ve gone wrong.


Well, a 500 error is about as useless to us as it is to you :wink:

What do your error logs say? Can you run your CGI script from the shell and, if so, does it work there? Are you sure that you’re serving up a Content-Type header from within your CGI script itself? Did you set your CGI script to be executable?

If you can answer those questions, it’ll help give us a better idea what’s going wrong with your script. If you’re willing to post your source code, that might be helpful too.


In addition to Alpicolas excellent and accurate comments, there are two more things that I have found are often the cause of that “helpful” 550 Internal server error when someone is just starting out:

  1. Not only does the script need to be executable, but it should be set with permissions of 755 on DreamHost (given the use of suEXEC). Less restrictive executable permissions can cause that error on DreamHost.

  2. If you edited the .cgi file on your computer (rather than using an native nix editor in the shell), make sure that you have saved the file with *nix style line-endings (which most good programmers’ editors will allow you to do) and that you have uploaded it to your account in ASCII mode.

These two issues are what I have found to be the most common on this forum.