Consider the example script below  which
	  counts the number of times it is 'visited.' 
#!/bin/sh
# CS 3000 Demo 
# CGI script that maintains short-term state,
# counting the number of accesses to it. 
# Output the document header followed by a blank line 
echo Content-type: text/html
echo
# Make a shell variable out of the 'arguments' 
# portion of the client's URL 
N=$QUERY_STRING
# emit the first few characters of the web page  
echo "<HTML>"
case "x$N" in
# in case of 'empty argument' set the variable N to 1, and 
# make the web page say this is the initial page 
x)     N=1
       echo "This is the initial page.<BR><BR>"
       ;;
# case of N = a number - add one to the number, and 
# arrange for the user to see the new number in the web page. 
x[0-9]*)  N=`expr $N + 1`;
          echo "You have displayed this page $N times.<BR><BR>"
          ;;
# Otherwise declare an error.  
*)        echo "The URL you used is invalid.</HTML>"
          exit 0
          ;;
esac
# Create an anchor that links back to this same script,
# except with a new QUERY_STRING equal to N. 
# Put the anchor into the web page, so the user can 
# employ it to refresh the display. 
echo "<A HREF=\"http://$SERVER_NAME$SCRIPT_NAME?$N\">"
echo "Click here to refresh the page.</A></HTML>"