CGI Help!

Hello, I’m trying to get started with CGI scripts which I’ve read I can use from anywhere. What I’m trying to do is run a classified ad script and I’ve read through the instructions many times and every time I try to run it I get a 500 Internal Server Error.

I’ve gone in and done the ‘pwd’ command and put that at the top of the script where it tells me to but I still get the error. I’ve tried renaming it with a .pl extension with no luck. I’ve tried it with and without the #! that preceedes is.

Can anyone tell me what I’m doing wrong? Is there any hope for me?

Thanks in advance for any help.


One common mistake beginners make with perl (and some old-timers, too), is that they upload a file in MS-DOS format to a Unix/Linux box. DOS text file format ends each line with a carriage return (Ctrl-M - ASCII 13) and line feed (Ctrl-J - ASCII 10) and Unix text file format ends each line of text with only an line feed. Perl chokes on those carriage returns.

The other common mistake people make is setting file permissions incorrectly. You should have scripts set at 755 and data files set at 644.

You also get an “internal server error” if your script won’t compile. A simple typo can do this.

If you run your perl script from the command line, you will get a more informative error message. It’s especially handy when you have a typo, because it tells you what like to look at.

Suggestion: You won’t eliminate every bug this way, but as a preliminary, it is a lot faster to check out your scripts on your own PC than to keep FTPing edits and telnetting to run the scripts. It’s very easy to download and install the ActiveState Perl distribution (free!) on your PC, and it comes with HTMLized documentation for not only Perl but many common Perl modules as well.

If you continue to have problems, please post with more details…