Shell Programming with Bourne shell
- test [ ]
-
Bourne shell constructs
- source filename [arguments] or . filename [arguments]
- while list do list done
- for name [ in word; ] do list ; done
- case word in [ pattern [ | pattern ] ... ) list ;; ] ... esac
- && logical AND
- || logical OR
- { list; } group commands
- ( list ) run commands in a sub-shell
- trap [arg] [sigspec]
- comment #
- null command :
Chebucto CGI shell program standard preprocessing
Please note: formatting gets lost with the HTML display.
- Bourne shell header
- !/bin/sh
- Redirect error output to a file
- exec 2>>/ccn/logs/test.`date +%y%m%d`
- Read system variables
- [ -f /etc/csuite.conf ] && . /etc/csuite.conf &&
[ -f "$CS_VARS1" ] && . $CS_VARS1 || {
echo "<h1>ERROR: could not find system variable file.</h1>"
exit 1
}
- Path specification
- PATH=$SYSPATH; export PATH
- PATH=$CGI_PATH; export PATH
- HTML header specification
- echo "Content-type: text/html"
echo
- # To report environment and exit
- #
#[ -f $CS_CGI_LIB/cgi-env ] && . $CS_CGI_LIB/cgi-env && read line &&
#echo $line | sed 's/&/\
#/g' && exit 1
- # To check remote address
- #if [ -z "$REMOTE_ADDR" ]; then
# echo "<h1>ERROR: missing remote address...who are you!<h1>"
# exit 1
#fi
- # to process QUERY_STRING
- [ -n "QUERY_STRING" ] && eval `clean-qs "$QUERY_STRING"`
- # to process form fields
- if [ "$REQUEST_METHOD" = POST ] && [ "$CONTENT_LENGTH" -gt 0 ]
then
eval `dd ibs=$CONTENT_LENGTH count=1 2>/dev/null | clean-post`
fi
- # for verbose error output
- #set -x
Programs called: (you must be logged into CCN to see these files)
- /etc/csuite.conf
- /ccn/lib/vars1
- clean-qs
- clean-post