> Text Only Version 
SFU Crest Simon Fraser University Sitemap
A - Z Directory
SFU Home Webmail Online Services mySFU Search SFU.ca
 

IT Services Home

Web Publishing

How do I install my own CGI scripts on cgi.sfu.ca?

Non-secure Server | Secure Server | Troubleshooting Errors

This service is available to faculty, staff, student and sponsored accounts.

Those of you using Perl for your CGI programs will find Perl at /usr/local/bin/perl on fraser.sfu.ca. That is, the first line of your program should read

#!/usr/local/bin/perl

You have a limited “quota” of disk space under your SFU Computing account, some of which you may already be using for other purposes. To check out how much space you are using and how much you have available, log into fraser.sfu.ca and type this:

quota -v

This will return how much disk space you are using and what your quota is, in kilobytes. For example, the usage number 12718 would indicate that you are using over 12 megabytes.

Non-secure server
  • Log into fraser.sfu.ca. If you haven’t already done so for your other web pages, make a directory called pub_html:

    mkdir pub_html

  • Permit this directory as follows:

    chmod 755 pub_html

  • Change into this directory:

    cd pub_html

  • Create a sub-directory called cgi-bin within pub_html to hold your CGI’s:

    mkdir cgi-bin

  • Permit cgi-bin like this:

    chmod 711 cgi-bin

  • Place your CGI programs in the cgi-bin sub-directory (using a Unix editor, or transfer into the directory using scp or FTP).
  • Your CGI files must end in the suffix .cgi.
  • Permit your CGI files like this:

    chmod 700 filename.cgi

  • The URL for your CGI program will be:

    http://cgi.sfu.ca/~yourID/cgi-bin/filename.cgi

    Replace yourID with your SFU Computing ID.

    Note the server name is cgi.sfu.ca NOT www.sfu.ca.

Secure Server
  • Log into fraser.sfu.ca. Create a directory called sec_html:

    mkdir sec_html

    Permit this directory as follows:

    chmod 711 sec_html

  • Place your CGI programs in this directory (using a Unix editor, or transfer into the directory using scp or FTP).
  • Your CGI files must end in the suffix .cgi.
  • Permit your CGI files like this:

    chmod 700 filename.cgi

  • The URL for your CGI program will be:

    https://cgi.sfu.ca/~yourID/filename.cgi

    Replace yourID with your SFU Computing ID.

    Note the server name is cgi.sfu.ca NOT www.sfu.ca, and you call it with https NOT http.
Troubleshooting Errors

If you are transferring your Perl program from another system (that is you are not creating the .cgi file directly on fraser using a text editor there), a common problem is that the file does not have the correct line-ending characters in it. fraser (cgi.sfu.ca) is a Unix machine and expects line-ending characters to be in Unix format.

If you create your .cgi file on a Microsoft Windows system, for example, and then transfer it to fraser in binary mode, fraser will not understand where line endings are in your file and you will get a “Server Failed” message.

To prevent or fix this problem try one of the following methods:

  • Ensure your FTP or scp file transfer program is set to send your .cgi files in Text (also sometimes called ASCII) mode. When a file is transferred in Text mode, the line ending characters are automatically translated for you.
  • Use a text editor that allows you to set the type of line-ending characters to use. Usually a programmer’s text editor or web publishing text editor will allow you to set the line ending type appropriately. The appropriate setting for fraser/cgi.sfu.ca is “Unix”
  • You can also use the dos2unix command on fraser to translate your file from Windows/DOS line-endings to Unix. Assuming your file was in your pub_html/cgi-bin folder and called mytest.cgi, you could convert that file to Unix from Windows/DOS called mytestnew.cgi by using the following commands:

    cd ~/pub_html/cgi-bin
    dos2unix -ascii mytest.cgi > mytestnew.cgi
    chmod 700 mytestnew.cgi

    The final “chmod” command sets the permissions for the new file appropriately so that the file is executable on the web since the dos2unix command doesn’t copy the permissions for the source file to the new file.

Terms & Conditions Questions or comments? E-mail help@sfu.ca

Copyright © Simon Fraser University, All Rights Reserved

Valid XHTML 1.0! Valid CSS!