Script Comments - use them!

# ..........................................................................
# This is a script comment. Anything on a line following the '#' is ignored.
# ..........................................................................

How will this script be executed?

# !/bin/sh

# The line above specifies that the routine is to be executed by the program
# 'sh' located in the '/bin' directory.

# ..........................................................................

# It MUST be on the first line in the first column! The '#' and the space
# _ARE_ part of the command

# ..........................................................................

Specifying Output Format


echo Content-type: text/html
echo

# Content type can also be 'text/asci' which is interpreted by the browser as
# being pre-formatted
# In addition, it is necessary to echo a blank line which is part of the CGI
# standard


Reading System Variables

#
# read system variables
#

[ -f /etc/csuite.conf ] && . /etc/csuite.conf &&
        [ -f "$CS_VARS1" ] && . $CS_VARS1 || {
                echo "ERROR: could not find system variable file."
                exit 1
        }
# This code includes error checking that confirms the existance of the config
# file.

Example of a Simple Shell Program



#.........................Comment....


echo 'chmod +x $1' >mx  # Create a file named mx containing the chmod command


chmod +x mx             # Make mx itself executable


#........................ The file to be made executable is passed to mx
#........................ as the the first (command line) argument
#........................ Now instead of typing

chmod +x test1

#........................ You only have to enter

mx test1                # would make the file test1 executable

#........................ This saves only a little typing... but it is
#........................ possible to create more comple routines that are
#........................ more valuable!