Getting CGI scripts working on the campus web server takes a few steps, but it is possible.

If you have a script named script.py from the CMPT 165 web server…

  1. Rename the file script.cgi .
  2. Add this line as the first in script.cgi:
    #!/usr/LOCAL/bin/python

    The # must be the very first character in the file.

  3. The file must be a Unix-format text file. If your text editor allows you to save the file as Unix text, do that. If not, you can convert it on the server (see step 5).
  4. Your campus web space is in the pub_html directory on fraser.sfu.ca. You can upload files there by following the instructions provided by ACS.

    You must put any Python programs (or other scripts) in the cgi-bin directory (which should be inside pub_html). So, upload the file to pub_html/cgi-bin/script.cgi in your home directory.

  5. If you haven't already, this would be a good time to convert the file to Unix text:
    dos2unix pub_html/cgi-bin/script.cgi pub_html/cgi-bin/script.cgi

    The file's permissions must be set so that it is a Unix executable program. Log into fraser.sfu.ca with SSH (or telnet if you must) and type this command:

    chmod 0755 pub_html/cgi-bin/script.cgi
  6. You should then be able to access the script at this URL:
    http://cgi.sfu.ca/~userid/cgi-bin/script.cgi

    Notice that the server is cgi.sfu.ca, not www.sfu.ca.