University of Minnesota
Computer Science & Engineering Help Pages
/

CGI Frequently Asked Questions

What Perl path should I have at the top of my script?

Your Perl CGI script should begin with:

#!/soft/perl5.8.7-bin/perl -w

What Python path should I have at the top of my script?

Your Python CGI script should begin with:

#!/soft/python-2.5-bin/python

Why won't my Python .py file execute?

The way our server is configured, you need to name your executable CGI scripts with the .cgi extension.

How should permissions be set on my CGI script?

  • Your home directory should have permissions of 701
  • Your .www (and any sub-directories containing your scripts) should have permissions of 701
  • Your CGI scripts should have permissions of 701
  • Files that your cgi script needs to read (for example an image file) should have permissions of 604

If you're not sure how to do this, see the CGI scripting Tutorial for detailed instructions on setting up a CGI script.

Note: Make sure that your CGI scripts and the directories that your CGI scripts are in are not group or world writable, otherwise our server will not execute them.

For security reasons you should never make your files or directories world writable and you should have a good understanding of the security implications before you make any files or directories group writable. This is especially true of web-accessible files and directories.

Do the owner and group of my CGI script matter?

Yes!

  • The CGI script and the enclosing directory must be owned by you.
  • The group of the file and the enclosing directory must be the same as your default group.

To find your default group use the id command. The value returned for gid will be your default group. (number and name)

Failing to set the owner and group correctly will result in an Internal Server Error.

How can I tell if my CGI script is producing the correct output?

Run your script from the command line. Simply cd to the directory containing the script, and type ./<scriptname.cgi>, where <scriptname.cgi> is the name of your CGI script. The first line of output returned should be:

Content-Type: text/htm

followed by a newline and then the output of your script. If the above line is not produced, or it's not followed by a blank line and then some content, an Internal Server Error will be displayed. Also, you might find that the script produces the following prompt when you run it:

(offline mode: enter name=value pairs on standard input)

If this happens, type control-D and the output of the script will be displayed.

Where can I find the Apache error logs?

Check the Apache Error Logs Page for information on where to find and how to access error logs.

What else can I do if I'm still getting Internal Server Errors?

First, re-check the answers to the questions and the steps outlined in the CGI tutorial.

Most CGI-related problems are caused by one of the above requirements not being met. Also, be sure to check the Apache Error Log to see what error message is being generated. If you have double-checked the CGI tutorial and the FAQs on this page and you are still experiencing problems getting your scripts to run, contact Systems Staff.

What do I do if I get an error when I try to run a script on my Windows computer?

If you are trying to run a script on a Windows computer, you may get an error that looks similar to this:

[date][error][client] suexec failure: could not open log file
[date][error][client] fopen: Permission denied
[date][error][client] Premature end of script headers: ruby.cgi

First, Check to make sure you don't have any strange newlines. It could be that you have Windows newline characters that are causing problems. SSH to one of our Solaris machines and type the following command:

% dos2unix <<file>> <<file>>

This command will convert Windows newline characters to Unix ones and clear up the error.

Contact: 1-213 Keller Hall, 200 Union St SE, Minneapolis, MN 55455   Phone: (612) 625-0876   Email: operator@cs.umn.edu