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/python
The
#
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_html
directory 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-bin
directory (which should be insidepub_html
). So, upload the file topub_html/cgi-bin/script.cgi
in 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.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
-
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
, notwww.sfu.ca
.