Gold University of Minnesota M. Skip to main content.University of Minnesota. Home page.
 
 

What's inside.

Account Management

CSE Wiki

E-mail

Hardware and Media

Network and Wireless

Offsite Access

Printing

Processes

Security and Passwords

Software and Tools

Systems Staff

Web Development

 

Help Home

CSE Home

 
 
 
 
 

 
  Home > Web > CGI Frequently Asked Questions

CGI Frequently Asked Questions


I'm writing a Perl script. 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

I'm writing a Python script. 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/html

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 error logs?

Depending on the type of account you have, you can find the output of the error logs with the following commands:

IT Labs: tail -f /web/logs/www-users.itlabs_error_log/error_log
CS: tail -f /web/logs/www-users.cs_error_log/error_log

The error logs contain the output created when your CGI script generates an error. The -f flag will cause the file to remain open and new error messages will be appended to the terminal output as they are created. This can help you debug the CGI script.

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

First, re-check the answers to the above 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 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.

 
The University of Minnesota is an equal opportunity educator and employer.
CSE Online Help