If you find your .cgi script throws an error, first view the CGI overview article. In that article is a section titled Running a CGI script at DreamHost. You can also check your site's error log file. View the following article for details:
The best way to debug any CGI is to run it directly on the server. Log into your server via SSH, and then run it using the following command:
Your terminal will return whatever is meant to be sent to the user's web browser.
You will often receive a message stating the general problem and the line number it occurs on. Usually, it is best to fix the first error that comes up, as that will often help with errors that occur further down the script.
Carriage returns in Perl scripts
Perl scripts in particular will occasionally mention a problem caused by carriage returns within the script. Perl has problems executing files with carriage returns, which are usually caused by scripts being edited in many Mac or Windows PC-based text editors (which natively use carriage returns to mark line endings).
You should only use a text editor that gives you an option to save with 'Unix-style' line endings. Notepad++ is a good choice:
What if I don't want .pl, .py, or .cgi files to run as CGI scripts?
If you'd rather have .pl, .py, or .cgi files displayed in the browser rather than executed as scripts, simply create a .htaccess file in the relevant directory with the following content:
RemoveHandler cgi-script .pl .py .cgi
If you're using SSH to connect, you can then create the .htaccess file by running the following command:
[server]$ echo "RemoveHandler cgi-script .pl .py .cgi" > .htaccess
Good resources for Perl CGI scripters
Perl is by far the most common language used to write CGI scripts. A fairly easy learning curve, coupled with tons of freely available source code, makes it a perfect choice for the beginning (and advanced) web coder. One of its greatest strengths is that the language was written with text processing in mind. Given that the web is almost nothing but text, it's a perfect match.
You can download the latest version of Perl at the official Perl site:
This site also contains a lot of great general information about writing Perl and Perl CGI scripts. There are also numerous online tutorials and books available to help you get started.
The sites below offer numerous scripts that you can use with a CGI-enabled DreamHost account. Some are better than others, so you should shop around before deciding on a given script.