#!/bin/ksh
# gengmtest2 - Author: Edwin Arneson - $Revision$ - $Date$
# Script to take a data file with garage sale address information from
# classified.van.net and generate a HTML file that will allow the
# loading of place marks using the Google Maps API
# This uses the example script http://www.google.com/apis/maps/documentation/geocoder2.html.
# FORMAT: gengmtest2
# CHANGE HISTORY:
# 070712 EJA 1.1 - Created
# CALLED BY:
# CALLS:
# SEE ALSO:
# SCRIPTS:
# PERMISSIONS:
# HOSTS THIS FILE IS IDENTICAL ON:
# FILES:
# GLOBALS:
# LOCALS:
# COMMANDS:
# INPUT:
# OUTPUT:
# OUTPUT USED BY:
# EXAMPLES:
# HINTS:
# RESTRICTIONS:
# BUGS:
# WARNINGS:
# 40 - The localize script could not be found. Global machine settings can not be set.
# ERROR CODES:
# 51 - An unknown option was passed to the script, or syntax of the parameters is wrong.
# 56 - The USAGE was requested using -z or -?.
# DIAGNOSTICS:
# RCS.SH VERSION: 00010
# RCS INFORMATION:
# $Id$
# $Author$
# $Date$
# $Revision$
# $Source$
# $State$
#######
####### Initialization
#######
# Special check for first parameter of "-x" to turn on tracing of the script execution
if [[ "$1" = "-x" ]] ; then
set -x
fi
# Find and execute the localization script designed to set common environment variables based name characteristics of the executing computer
binDir=`dirname $0` # get the directory this script is in and check for localize there
if [[ -r "$binDir/localize" ]] ; then
. $binDir/localize
else
echo "$0: WARNING 40 - The localize script could not be found. Global machine settings can not be set."
fi
# Ensure these three are set
if [[ -z "$localhost" ]] ; then localhost="`uname -n`" ; export localhost ; fi
if [[ -z "$awkname" ]] ; then if [[ -x "/usr/bin/nawk" ]] ; then awkname="nawk" ; else awkname="awk" ; export awkname ; fi ; fi
if [[ -z "$OStype" ]] ; then OStype="`uname -s`" ; export OStype ; fi
#######
####### Functions
#######
#######
####### Other variables
#######
basename=`basename $0`
USAGE="$basename
\$Revision$ - \$Date$
usage: $basename [-x]* [-X]*
<-x> does 'set -x' (may be used in functions and external script calls)
<-X> sets debugging level--the number of times -X is specified"
debuglevel=0 # -X: stores the number of times -X is specified (debugging level)
xlevel=0 # -x: stores the number of times -x is specified (for optional "set -x" call in functions) and does 'set -x'
#######
####### Parse parameters.
#######
while getopts :xXz optchar ; do
if [[ $debuglevel -ge 1 ]] ; then echo ">optchar=$optchar< >OPTARG=$OPTARG> >OPTIND=$OPTIND<" ; fi
case $optchar in
x) xcmd="$xcmd -x" ; ${xcmd:+set -x} ; let "xlevel=$xlevel + 1" ;; # xcmd stores any -x parameters for passing to other scripts
X) Xcmd="$Xcmd -X " ; let "debuglevel=$debuglevel + 1" ;; # Xcmd stores any -X parameters for passing to other scripts
\?|z) echo "$USAGE" >&2 ; exit 56 ;;
*) if [[ -z "$OPTARG" ]] ; then
case "$optchar" in
?) errflag="-$optchar" ;;
+?) errflag="$optchar" ;;
*) errflag="unknown1" ;;
esac
else
errflag="$OPTARG"
fi
echo "$basename: ERROR 51 - Unknown option >$errflag<" >&2
echo "$USAGE" >&2
exit 51
;;
esac
done
shift `expr $OPTIND - 1`
#######
####### Additional checks
#######
#######
####### Main processing
#######
cd /Library/WebServer/Documents
cat gmtest2.1 >gmtest2.html
cat gmtest2.in \
| awk '
BEGIN{
cnt=0
}
{
pos=index($0, "|")
if($2=="Garage" && $3=="Sales")
i=1
else if($1=="")
i=1
else if($1=="EOF")
exit
else if($1=="CITY=")
citystr=substr($0, 7)
else {
cnt++
printf("", 39, 34)
printf("%d %s
\n", cnt, $0)
# printf("%s
\n", 34, 34, 34, 39, $0, 39, 34, $0)
}
}
' >>gmtest2.html
cat gmtest2.2 >>gmtest2.html
#######
####### Cleanup
#######
#######
####### The end.
#######
exit