Problems 14
Home Up Review Problems 1 Problems 2 Problems 3 Problems 4 Problems 5 Problems 6 Problems 7 Problems 8 Problems 9 Problems 10 Problems 11 Problems 12 Problems 13 Problems 14 Problems 15 Problems 16 Subnets

 

Perl CGI Scripting using CGI module

Due: Friday (January 8) and next week (January 11 - 13)

Purpose:

Familiarize yourself with the Perl CGI module for simplified CGI programming.

Assignment: Chapter 19: CGI Programming

Read the beginning of Chapter 19 in Learning Perl and upload each of the examples as you understand how it works.

On NETSRV, you need a different path to get Perl 5.004 so that you may use the "CGI" module.  (See my recent note about Perl 5.004 in the Announcements news group.)  You cannot use #!/usr/local/bin/perl; you must replace it with #!/opt/perl5.004/bin/perl.

You already know how to upload a CGI script to NETSRV and make it executable on NETSRV.   Try the example on page 186/187.  (Remember to change the path to Perl at the top of the script.)

Continue on to try the other form examples in the chapter.  As you finish each example, email me the URL of your script.

When you get to uploading and running the GuestBook program (page 194), you will need a bit of Perl to create the temporary chat file and give it 0666 permissions, since you don't have direct access to the Unix shell on NETSRV.  You can write a very simple CGI script to do this for you.  The book suggests that you name the chat text file /usr/tmp/chatfile; this may cause problems if two identical GuestBook programs use the same name.  Pick a different file name for your own GuestBook.

When you reach the section on Web Automation with LWP, be advised that NETSRV does not have LWP installed.  Skip that section.  We will do it using Linux and the Apache web server.

FTP Site

At the very back of your "Learning Perl" book, you'll find a page titled "How to stay in touch with O'Reilly".  It gives an FTP address from which you can download some of the larger examples in the O'Reilly books.

Most O'Reilly examples are Unix tar/compressed files (suffix *tar.gz) and you unpack them as follows (see "man gunzip" and "man tar" for details):

    $ mkdir somedir
    $ cd somedir
    $ gunzip <../examples_tar.gz | tar xf -
    $ ls
    ch01_hello            ex_06-3               ex_11-3
    ch01_last             ex_06-4               ex_12-1
    ch01_secret           ex_07-1a              ex_12-2a
    ch19_guestbook        ex_07-1b              ex_12-2b
    ch19_icecream_4       ex_07-1c              ex_13-1
    ch19_sort_uniq_links  ex_07-1d              ex_13-2ex_02-1
    ex_07-1d2             ex_13-3
    ex_02-2               ex_07-1e              ex_13-4ex_02-3
    ex_07-2a              ex_13-5
    ex_02-4               ex_07-2b              ex_14-1
    ex_03-1a              ex_07-2c              ex_14-2
    ex_03-1b              ex_07-3               ex_14-3
    ex_03-2               ex_07-4               ex_14-4
    ex_03-3               ex_07-5               ex_14-5
    ex_04-1               ex_08-1               ex_15-1
    ex_04-2               ex_08-2               ex_15-2
    ex_04-3               ex_08-3               ex_15-3
    ex_04-4               ex_09-1               ex_15-4a
    ex_04-5a              ex_09-2               ex_15-4b
    ex_04-5b              ex_10-1               ex_16-1
    ex_05-1a              ex_10-2               ex_17-1
    ex_05-1b              ex_10-3               ex_17-2
    ex_05-2               ex_10-4               ex_18-1
    ex_06-1               ex_11-1               ex_19-1
    ex_06-2               ex_11-2               ex_19-2
    $ cp ch19_icecream_4 icecream.cgi
    $ ftp netsrv.algonquincollege.com
    ...upload icecream.cgi to your cgi-bin...
    $ telnet netsrv.algonquincollege.com
    ...make the uploaded file executable on NETSRV...
    $ netscape
    ...try it!...
    http://www.algonquincollege.com/cgi-bin/icecream.cgi 

Hand In: 

Send me an EMail message with the URL of each Chapter 19 finished script on NETSRV as soon as you complete it (so I have a sense of how fast you are progressing).

Build a CGI Script Gallery on your home page. Assemble links to all your scripts in one place on your NETSRV home page (in your index.html file, or in another file linked to by your index.html file).  The section when displayed might look like this:

My Cool CGI Scripts

Some beginning scripts copied from Ian Allen (idallen@freenet.carleton.ca).
Here is some information about NETSRV, including some information about today.

From the O'Reilly book "Learning Perl", page 190/191.
I offer you a virtual Ice Cream Stand.  Click right up!

From the O'Reilly book "Learning Perl", page nnn.
A demonstration of ....

...etc...

Each section would contain an HTML tag to reference each of your completed CGI scripts.

Additional material:

ftp://ftp.ora.com/published/oreilly/nutshell/learning_perl2/   Perl scripts

http://web.oreilly.com/  O'Reilly Web resources

The Idiot's Guide to Solving Perl CGI Problems

Perl CGI Programming FAQ

The WWW Security FAQ

FMTEYEWTK (Far More Than Everything You've Ever Wanted To Know)