Programming Exercise I Construction (Cont.)

  1. Calling a CGI Script (Linux Shell)
  2. CGI (Common Gateway Interface) is a standard for running external programs from a World Wide Web HTTP server. CGI specifies how to pass arguments to the executing program as part of the HTTP request. It also defines a set of environment variables. Commonly, the program will generate some HTML pages which will be passed back to the browser. For the previous interface, the following CGI script ListCourses.cgi is activated once a button is clicked:

    ~/public_html/cgi-bin/demo/10/ListCourses.cgi
    #!/usr/bin/bash
    # To set up the Oracle environment dynamically
    CLASSPATH=.:/usr/lib/oracle/12.1/client64
    CLASSPATH=$CLASSPATH:/usr/lib/oracle/12.1/client64/lib/ojdbc7.jar
    CLASSPATH=$CLASSPATH:/usr/lib/oracle/12.1/client64/lib/ottclasses.zip
    export CLASSPATH
    
    # Calling the CGI Perl script 
    /usr/bin/perl  ListCourses.pl

    These statements are the minimum, but they work so far. We may need to add more statements later if necessary. The last statement calls the CGI Perl script,
    ListCourses.pl . Note that

    • “Internal Server Error” will be issued if the Perl script does not include either one of the following two commands:
         print( "Content-type: text/html\n\n"  );
         print( "Content-type: text/plain\n\n" );
    • This script is for setting the environment variables for JDBC. If JDBC is not used in this function, you may skip this step.



      β€œIt is better to remain silent at the risk of being thought a fool,    
      than to talk and remove all doubt of it.”    
      ― Maurice Switzer, Mrs. Goose, Her Book