Weeks 6 - 8

UNIX shell scripts with CGI

quiz? Let's do that Friday October 14th


Assignment 4: Due Friday, October 10th

Assignment #5: Due: Monday, November 7th (note change of due date)

Part A -- Estimating John Hancocks in the United States.  -- Note: owing to complexities in Census bureau's rework of the population clock as well as new security constraints on obsidian's CGI environment, just plug in this comma-delimited number into your script for the current population :

324,809, 640 (as of 11:06 pm October 28, 2016)

Part B -- submitting forms with methods GET and POST

Some useful (?) things for using UNIX:

Command status, STDERR, STDOUT and STDIN

You may want to revisit the page on doing arithmetic in UNIX -- particularly the bc command.

and arithmetic: a quick review of some techniques

A little script that may help with the parsing of web pages (using lynx -dump) can be seen here. (Note: your version of UNIX/Linux may use "links" instead of "lynx").

Here's a link on how to generate random numbers in the shell, using $RANDOM.

Or, here's a little PERL program you can use to return an integer between 0 and 222:

$ /homes/ddailey/rand 223
$ /homes/ddailey/rand 223
$ /homes/ddailey/rand 223
$ /homes/ddailey/rand 223

Other topics:

(See also: How to make a cgi/shell script run over the web)

How to make an executable script run over the web: 

1. Place it in yourhomedirectory/public_html/cgi

2. Add three "magic" lines to the beginning of the code:

echo "Content-type: text/html"

Let's analyze some ways of calling such a script. 

through a form submission
let the script rebuild itself dynamically, like this
frame the content in a page with multiple frames.


use AJAX (an example that looks up words in a dictionary as you type)

Other ways of sending data to the server