Slide 3.8: CGI (Common Gateway Interface)
Slide 3.10: REQUEST_METHOD: GET or POST
Home

Writing CGI Scripts


  1. Apply for a UND Aerospace Unix Account. Apply for a UND Aerospace Unix account at the helpdesk in Room 160, Clifford Hall. Do not forget to bring your student ID card with you.


  2. Check the CGI Help Pages.

  3. Create a Sub-Directory “~/public_html/cgi-bin” under the Root Directory. Create the directory by using the command mkdir:
      shell> mkdir ~/public_html
      shell> mkdir ~/public_html/cgi-bin
    where the symbol ~ is the user's root in the Unix file system.


  4. Create a CGI Script. Create/edit a CGI script in the cgi-bin directory. The cgi-bin directories are set up so that they do not serve plain HTML/WML pages; they just execute a given CGI script. An example of a CGI Perl script is ~/public_html/cgi-bin/test.pl. Check the CGI Programming 101 for how to write CGI scripts.

    Note that a compiler, activated in a CGI script, can not successfully generate an object file if the source program results a warning message.


  5. Open the CGI Script. Note that this step is no longer needed here because the new web server treats the one executing a script as the script's owner.
          shell> 
    That is after
      shell> chmod 700 test.pl
    test.pl still can be activated from the Web without problems and it acts like the owner being executing the script.



    Open CGI scripts to let the browser, which is not the owner of the scripts, access them by using the command chmod :
      shell> chmod 755 ~/../userid
      shell> chmod 755 ~/public_html/
      shell> chmod 755 ~/public_html/*
      shell> chmod 755 ~/public_html/cgi-bin/
      shell> chmod 755 ~/public_html/cgi-bin/*
    Note that the above commands may not be complete. You have to open all the files in the public_html directory.

    If CGI writes to your directory, such as ~userid/public_html/out/, then you need to open that directory. For the example of that directory:
      shell> chmod 755 ~/../userid
      shell> chmod 755 ~/public_html/
      shell> chmod 777 ~/public_html/out/
    Note that if you write the file to the directory where the CGI script is, this will cause Internal Server Error, that is, try NOT to do the following:
      shell> chmod 777 ~/public_html/cgi-bin/
       


  6. View the Execution Results of the CGI Scripts. You can then check the execution results of your CGI scripts on the browser. For the example of the CGI script ~/public_html/cgi-bin/test.pl, the results are at the location:
      http://people.aero.und.edu/~userid/cgi-bin/test.pl