#!/bin/sh
#=======================================================================
# Wrapper to catch CGI errors
#=======================================================================
dir=`dirname $0`
stub=`basename $0 .cgi`
tmp1="/tmp/$stub.$$.out"
tmp2="/tmp/$stub.$$.err"
>>$tmp1
>>$tmp2
pl="$dir/$stub.pl"
if [ -f "$pl" ]; then
if [ ! -x "$pl" ]; then
echo "Content-type: text/plain"
echo "Status: 500"
echo
echo "$pl is not executable"
else
"$pl" >$tmp1 2>$tmp2
fi
else
perl -e 'use Local; ::cgirun("cgi/'$stub'")' >$tmp1 2>$tmp2
fi
if [ -s $tmp2 ]; then
echo "Content-type: text/plain"
echo
echo ">>>Errors:"
cat $tmp2
echo
echo ">>>Output:"
fi
cat $tmp1
rm -f $tmp1 $tmp2
exit 0
Note. The script use two independent methods for starting the wrapped perl script:
1 First it tries to find a perl script named basename.pl where basename is the name of the wrapper script. 1 If such a file is not found it assumes that the basename may be used by the cgirun function in the Local.pm configuration perl module using cgi/basename as argument.
Finally, when developing new CGI perl scripts it is often wise to limit the execution time allowed. To achieve a CPU time limit of for example 20 seconds the following line may be added:
ulimit -t 20Back to the main installation instruction.

