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…
-
Rename the file
script.cgi. -
Add this line as the first in
script.cgi:#!/usr/LOCAL/bin/pythonThe
#must be the very first character in the file. - 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).
-
Your campus web space is in the
pub_htmldirectory onfraser.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-bindirectory (which should be insidepub_html). So, upload the file topub_html/cgi-bin/script.cgiin your home directory. -
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.cgiThe file's permissions must be set so that it is a Unix executable program. Log into
fraser.sfu.cawith SSH (or telnet if you must) and type this command:chmod 0755 pub_html/cgi-bin/script.cgi -
You should then be able to access the script at this URL:
http://cgi.sfu.ca/~userid/cgi-bin/script.cgiNotice that the server is
cgi.sfu.ca, notwww.sfu.ca.