CGI Startup Shell Script
The shell script "bwu.sh " is copied to a cgi directory and named "demobbw.sh". Most servers contain a standard "cgi-bin" directory in the directory mapping structure defined in the server configuration files.
#!/bin/sh
# Copyright (C) 1996 by Allen Miglore. All rights reserved.
# bwu.sh is a standard shell script that can be used to start a
# BBx/Pro5 task in a UNIX environment. This script can be copied
# to the cgi directory, given whatever name you need, or it can
# be used as is by other scripts that would set PGM and optionally
# MEM before exec'ing this script.
# Set PGM and MEM to desired values for the bbx program and start size.
# (these can be set in another script, that execs this one.)
The PGM environment variable must be set to the name of the Business
BASIC program (in this case, "demobbw.bbx"). If the program
requires more or less than 512 pages, the MEM variable can also be set.
The values for ERRORLOG , CONFIG , AND BBXEXEC must also be modified to
match the configuration. The file name ERRORLOG stores messages related
to problems starting Business BASIC. CONFIG points to the PRO/5 configuration
file used by BASIC Web Utility programs, and BBXEXEC is the name of the
PRO/5 executable.
The CONFIG file must be edited so the PREFIX contains the BASIC Web Utility
installation directory.
PGM=demobbw.bbx
#MEM=512
# modify these values per your bbx configuration
MAXTRIES=5
ERRORLOG=/usr/lib/pro5/webb/error.log
CONFIG=/usr/lib/pro5/webb/bbweb.cnf
BBXEXEC=/usr/lib/pro5/pro5
MEM=${MEM:=512}
if [ "$PGM" = "" ]
then
echo "Content-type: text/plain"
echo ""
echo "Invalid pgm argument"
exit
fi
umask 0
RETRIES=0
This section starts PRO/5. If it fails, it retries, sends the user an HTML message, and records the error to the ERRORLOG file.
until [ $RETRIES -gt $MAXTRIES ]
do
$BBXEXEC -q -c$CONFIG -m$MEM $PGM - "$@" 2>/tmp/bberr.$$
if [ -s /tmp/bberr.$$ ]
then
RETRIES=`expr $RETRIES + 1`
sleep 1
read msg </tmp/bberr.$$
rm /tmp/bberr.$$ 2>/dev/null
else
RETRIES=99
rm /tmp/bberr.$$ 2>/dev/null
fi
done
if [ ! "$RETRIES" = "99" ]
then
echo `date` $msg >>$ERRORLOG 2>/dev/null
echo "Content-type: text/plain"
echo ""
echo "The database server is too busy. Sorry about that."
echo "Please try again later."
echo ""
echo "By the way, we have recorded this problem, and will add"
echo "capacity if it happens frequently."
fi