#!/bin/sh

##==============================================================================
#$ APPX_PRINT - Appx Printer Interface Script for Unix         Updated: 09/10/04
##------------------------------------------------------------------------------
##
##  This script will submit the Appx report specified on the 
##  the command line to print spooler.
##
##  The format of the command line is expected to be:
##
##	<script-name> [-config=<config_file_name>] printfiles*
##
##  Where the "-config=<config_file_name>", if present, specifies
##  a configuration file to be used when submitting the given 
##  printfiles to the spooler.
##
##  A configuration file is expected to be a flat ascii file which 
##  should contain a list of spooler options, one per line, in 
##  the format:
##
##	-<option>=<value>
##
##  Options are processed in order of appearance.
##
##  Where "-<option>" is one of the following:
##
##	-mode=           [SPOOL | HOLD | KEEP]
##	-disposition=    [SCRATCH | SAVE | REQUEUE]
##	-copies=         # of Copies to Print
##	-notify=         [No | Yes]
##	-banner=         [No | Yes]
##	-format=         Filter script name
##	-priority=       Spooler specific Priority value
##	-date=           Spool Date as "CCYYMMDDhhmmssth"
##	-user=           OS User Name
##	-printer_name=   Appx Printer Name
##	-printer_id=     Appx Printer System Id
##	-printer_ctl=    Appx Printer Options
##	-printer_queue=  Appx Printer Device
##	-form_name=      Appx Form Name
##	-form_id=        Appx Form Queue or Class Name
##	-form_ctl=       Appx Form Options
##
##==============================================================================

# ###########################################################################
# NAME: BUILD_LP_OPTIONS
#
# DESCRIPTION:  This function will generate any special options needed by
#               the "lp" spooler.
#
# PARAMETERS:	none
#

BUILD_LP_OPTIONS ()
{
    LP_OPTIONS=""

    echo "Building spooler options for 'lp'..." >> $LOGFILE

    if [ -n "$FORM_ID" -a -n "$PRINTER_QUEUE" ]
    then

        # We have both a form id and a queue name, separate them
        # with a colon since that's what "lp" prefers

        LP_OPTIONS="-d$FORM_ID:$PRINTER_QUEUE $LP_OPTIONS"

    elif [ -n "$FORM_ID" ]
    then
 
        # We have only a form id
        LP_OPTIONS="-d$FORM_ID $LP_OPTIONS"

    elif [ -n "$PRINTER_QUEUE" ]
    then

        # We have only a queue name
        LP_OPTIONS="-d$PRINTER_QUEUE $LP_OPTIONS"
    fi

    #
    # Figure out the FREEZE setting for this print spooler
    #

    if [ "$FREEZE" = "Yes" ]
    then
        LP_OPTIONS="-c $LP_OPTIONS"
    fi
}

# ###########################################################################
# NAME: BUILD_LPR_OPTIONS
#
# DESCRIPTION:  This function will generate any special options needed by
#               the "lpr" spooler.
#
# PARAMETERS:	none
#

BUILD_LPR_OPTIONS ()
{
    LP_OPTIONS=""

    echo "Building spooler options for 'lpr'..." >> $LOGFILE

    if [ -n "$FORM_ID" -a -n "$PRINTER_QUEUE" ]
    then

        # We have both a form id and a queue name, separate them
        # with a colon since that's what "lp" prefers

        LP_OPTIONS="-P$FORM_ID:$PRINTER_QUEUE $LP_OPTIONS"

    elif [ -n "$FORM_ID" ]
    then
 
        # We have only a form id
        LP_OPTIONS="-P$FORM_ID $LP_OPTIONS"

    elif [ -n "$PRINTER_QUEUE" ]
    then

        # We have only a queue name
        LP_OPTIONS="-P$PRINTER_QUEUE $LP_OPTIONS"
    fi

    #
    # Figure out the BANNER setting for this print spooler
    #

    if [ "$BANNER" = "No" ]
    then
        LP_OPTIONS="-h $LP_OPTIONS"
    fi
    
    #
    # Figure out the NOTIFY setting for this print spooler
    #

    if [ "$NOTIFY" = "Yes" ]
    then
        LP_OPTIONS="-m $LP_OPTIONS"
    fi

    #
    # Figure out the FREEZE setting for this print spooler
    #

    if [ "$FREEZE" = "No" ]
    then
        LP_OPTIONS="-s $LP_OPTIONS"
    fi
}

# ###########################################################################
# NAME: BUILD_ULP_OPTIONS
#
# DESCRIPTION:  This function will generate any special options needed by
#               the "ulp" UniQueue spooler.
#
# PARAMETERS:	none
#

BUILD_ULP_OPTIONS ()
{
    LP_OPTIONS=""

    echo "Building spooler options for 'ulp'..." >> $LOGFILE

    if [ -n "$PRINTER_NAME" ]
    then
        LP_OPTIONS="-d$PRINTER_NAME $LP_OPTIONS"
    fi

    if [ -n "$FORM_NAME" ]
    then
        LP_OPTIONS="-f$FORM_NAME $LP_OPTIONS"
    fi

    LP_OPTIONS="-n$COPIES $LP_OPTIONS"
    COPIES="1"

#   UniQue only wants the 1st position of PRIORITY for CLASS
    if [ -n "$PRIORITY" ]
    then
        LP_OPTIONS="-C`echo $PRIORITY | cut -c 1` $LP_OPTIONS"
    fi

#   UniQue notify option
    if [ "$NOTIFY" = "Yes" ]
    then
        LP_OPTIONS="-m -A$USER $LP_OPTIONS"
    fi

    ULP_MODE="-Mleave"

    if [ "$MODE" = "SPOOL" ]
    then
        if [ "$DISPOSITION" = "REQUEUE" ]
        then
            ULP_MODE="-Mre"
        elif [ "$DISPOSITION" = "SCRATCH" ]
        then
            ULP_MODE="-Mdel,leave"
        elif [ "$DISPOSITION" = "SAVE" ]
        then
            ULP_MODE="-Mleave"
        else
            ULP_MODE="-Mleave"
        fi
    elif [ "$MODE" = "HOLD" ]
    then
        if [ "$DISPOSITION" = "REQUEUE" ]
        then
            ULP_MODE="-Mhold,re"
        elif [ "$DISPOSITION" = "SCRATCH" ]
        then
            ULP_MODE="-Mhold,del,leave"
        elif [ "$DISPOSITION" = "SAVE" ]
        then
            ULP_MODE="-Mhold,leave"
        else
            ULP_MODE="-Mhold,leave"
        fi
    fi

#   Banner?
    if [ "$BANNER" = "Yes" ]
    then
        LP_OPTIONS="$ULP_MODE,banner $LP_OPTIONS"
    else
        LP_OPTIONS="$ULP_MODE $LP_OPTIONS"
    fi
}

# ###########################################################################
# NAME: PROCESS_CONFIG( config_file_name )
#
# DESCRIPTION:  This function will read spooler options from the named
#               configuration file.
#
# PARAMETERS:	  $1 = Pathname of configuration file to be parsed
#

PROCESS_CONFIG ()
{
    echo "Processing config file $CONFIG_FILE..." >> $LOGFILE

    # Open the configuration file as file descriptor #3
    exec 3< $1

    # Now read through the configuration file, putting each line in $CFG_REC
    while read CFG_REC <&3
    do

        # Treat lines beginning with a "#" as comments
	if [ "$CFG_REC" = "\#*" ]
	then
	    continue
	fi

        # Process this line as if it were a command line argument
	PROCESS_OPTION $CFG_REC
	
    done

    # Close the configuration file
    exec 3<&-

    echo "" >> $LOGFILE
}

# ###########################################################################
# NAME: PROCESS_OPTION( option )
#
# DESCRIPTION:  This function will parse the given spooler option
#
# PARAMETERS:   $1 = Spooler option to be processed
#

PROCESS_OPTION ()
{
echo "      PROCESS_OPTION:  $1" >> $LOGFILE     # turn on to capture each Option
    case "$1" in
	-mode=*)
	    #  	This option contains the print mode for
	    #   this print job.  The value will be one of the 
	    #	following:
	    #		<blank>
	    #		HOLD   - queue but don't print files
	    #		SPOOL  - queue for printing ASAP
	    #   	KEEP   - do not queue files for printing
	    #		
	    MODE=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-disposition=*)
	    # 	This option specifies what to do with the print
	    # 	files after they have been printed.  The following
	    #	values should be expected:
	    #		<blank>
	    #		SCRATCH	- delete the file after printing
	    #		SAVE	- retain the file after printing
	    #		REQUEUE - requeue the file after printing
	    #
	    DISPOSITION=`echo $* | sed 's/^[^=]*=//'`
	    ;;		

	-copies*)		
	    #	This option specifies how many copies the 
	    #	user would like to print.  It contains the 
	    #   value of the "PRINT COPIES" PDF.
	    #
	    COPIES=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-notify*)
	    # 	This option is an interpretation of the 
	    #   "PRINT NOTIFY USER" PDF.  It will contain 
	    #	either "Yes", "No", or blank.
	    #
	    NOTIFY=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-banner*)
	    #	This option contains an interpretation of the
	    #	"PRINT BANNER" PDF.  It will contain either "Yes",
	    #	"No", or blank.
	    #	
	    BANNER=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-format*)
	    #	This option contains the value of the "PRINT
	    # 	FORMAT" PDF.
	    #
            #   This option will set the name of a format translation
            #   filter.  This filter is a script in the $APPXPATH/filters/
            #   directory.  The filter will have the the FORM_CTL value
            #   passed to it and it will have the print file data piped
            #   into it.  The filter should check the passed arguments to
            #   determine how to format the report data.  The results
            #   should be fed out from the scripts stdout descriptor to
            #   be piped into the print spooler.
            #
	    FORMAT=`echo $* | sed 's/^[^=]*=//'`
	    ;;
	
	-priority*)
	    #	This option contains the value of the "PRINT
	    #  	PRIORITY" PDF.  
	    #
	    PRIORITY=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-date*)
	    #	This option contains an interpetation of the
	    #	"PRINT SPOOL DATE" PDF.  It will be in the form
	    #	CCYYMMDDhhmmssth.  This date specifies when the 
	    #	user would like the report released to the printer.
	    #	
	    DATE=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-user*)
	    #	This option contains the Unix user name
	    # 	of the submitter.
	    #
	    USER=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-printer_name*)
	    #	This option contains the value of the "PRINT
	    #	PRINTER ID" PDF, which is the Appx identifier
	    #	for the destination printer.
	    #
	    PRINTER_NAME=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-printer_id*)
	    #	This option contains the OS name for the destination
	    #	printer.  This value comes from the Appx System 
	    #	Administration PRINTER file record whose key is 
	    #	determined by the "PRINT PRINTER ID" PDF.
	    #
	    PRINTER_ID=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-printer_ctl*)
	    #	This option contains user-defined options for the 
	    #	destination printer.  This value comes from the Appx
	    #	System Administration PRINTER file record whose key
	    #	is determined by the "PRINT PRINTER ID" PDF.
	    #
	    PRINTER_CTL=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-printer_queue*)
	    #	This option specifies the name of the queue to which
	    #	the given reports should be spooled.  This value comes
	    #	from the Appx System Administration PRINTER file 
	    #	record whose key is determined by the "PRINT PRINTER
	    #	ID" PDF.
	    #
	    PRINTER_QUEUE=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-form_name*)
	    #	This option contains the value of the "FORM ID" PDF, 
	    # 	which is the Appx identifier for the desired form.
	    #
	    FORM_NAME=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-form_id*)
	    #	This option contains the OS name for the destination
	    #	form.  This value comes from the Appx System 
	    #	Administration FORM file record whose key is 
	    #	determined by the "FORM ID" PDF.
	    #
	    FORM_ID=`echo $* | sed 's/^[^=]*=//'`
	    ;;

	-form_ctl*)
	    #	This option contains user-defined options for the 
	    #	destination form.  This value comes from the Appx
	    #	System Administration FORM file record whose key
	    #	is determined by the "FORM CTL" PDF.
	    #
	    FORM_CTL=`echo $* | sed 's/^[^=]*=//'`

	    # Replace any Windows style fonts names with mpage names
	    #
	    FORM_CTL=`echo $FORM_CTL|sed 's/\"Courier New\"/Courier/g'|sed 's/\"Letter Small\"/LetterSmall/g'`
	    ;;
    esac
}

# ############################################################################
# MAIN Program Logic Starts Here 
# ############################################################################
# Process the command line arguments, watching for a configuration file.
# 
# Stop as soon as we see the first argument which does not begin with a 
# hyphen.  The remainder of the command line is considered to be a list 
# of filenames which we pass straight to the spooler.
#

#
# Set up the log file to use.  We must mess around with the umask so that
# other users will also be able to manipulate the log file.
#

UMASK=`umask`; umask 00             # save and set the umask

LOGFILE=/tmp/appx_print.last
export LOGFILE

# use either of the following to initialize or accumulate LOGFILEs 

echo "=============================================================================" >  $LOGFILE
#echo "=============================================================================" >> $LOGFILE
                                                                                
umask $UMASK                        # restore original umask                

#
# Now, redirect STDERR to the logfile.
#

exec 3>&1 4>&2 1>>$LOGFILE 2>&1

#
# Do some routine logging.
#
                                                                                
echo "`grep '^[#][$]' $0|cut -b4-`" >> $LOGFILE
echo "=============================================================================" >> $LOGFILE

# set >> $LOGFILE             # dump current user's environment into LOGFILE         

echo >> $LOGFILE                                                               

echo "............. Parameters passed on command line ..........." >> $LOGFILE

echo $* >> $LOGFILE                 # record '$*' parameters into LogFile
echo    >> $LOGFILE

#
# Determine the location of our script file so we can locate the filters
#

CURRPATH=`echo $0|sed 's/\/[^/]*$//'`

#
# Get the OS name
#

OS_NAME=`uname`

#
# Define the spooler command to use when spooling the print file
#

if [ -z "$APPX_LP_CMD" ]
then

    echo "APPX_LP_CMD variable not set.  Looking for a spooler to use..." >> $LOGFILE

    if [ -z "`type ulp 2>/dev/null`" ]
    then

        echo "    'ulp' not found in the current PATH..." >> $LOGFILE

        if [ -z "`type lp 2>/dev/null`" ]
        then

            echo "    'lp'  not found in the current PATH..." >> $LOGFILE

            if [ -z "`type lpr 2>/dev/null`" ]
            then
                echo "'lpr' not found in the current PATH.  Defaulting to 'lp'" >. $LOGFILE
                APPX_LP_CMD="lp"
            else
                echo "    'lpr' found!  Setting APPX_LP_CMD=lpr" >> $LOGFILE
                APPX_LP_CMD="lpr"
            fi
        else
            echo "    'lp'  found!  Setting APPX_LP_CMD=lp" >> $LOGFILE
            APPX_LP_CMD="lp"
        fi
    else
        echo "    'ulp' found!  Setting APPX_LP_CMD=ulp" >> $LOGFILE
        APPX_LP_CMD="ulp"
    fi
else
    echo "APPX_LP_CMD already set outside of script." >> $LOGFILE
    echo " Using current value: $APPX_LP_CMD"         >> $LOGFILE
fi

echo "" >> $LOGFILE

#
# Set up some default values
#

FREEZE="Yes"                

COPIES=1                    
BANNER="No"                 
MODE="SPOOL"                
DISPOSITION="SCRATCH"       
NOTIFY="No"                 
USER=$USER                  
FORMAT=""
PRIORITY=""
DATE=""
PRINTER_NAME=""
PRINTER_ID=""
PRINTER_CTL=""
PRINTER_QUEUE=""
FORM_NAME=""
FORM_ID=""
FORM_CTL=""

CONFIG_FILE=""
PRINT_FILE=""
OTHER_ARGS=""
LP_OPTIONS=""

#
# Parse out the command line arguments
#

count=$#

while [ $count -gt 0 ]
do
    case "$1" in

        #
        # Help
        #
        -[?]|--help)
		exec 1>&3 2>&4 
                grep '^[#][#$]' $0|cut -b3-|more
                exit 0
                ;;

        #
        # Version
        #
        --version)
		exec 1>&3 2>&4 
                grep '^[#][$]' $0|cut -b4-|more
                exit 0
                ;;

        #
        # History
        #
        --history)
		exec 1>&3 2>&4 
                grep '^[#][+]' $0|cut -b4-|more
                exit 0
                ;;

	# 
	# Check for config file
	#
	-config=*) # set config file to parse
	        CONFIG_FILE=`echo $1 | sed 's/^[^=]*=//'|sed 's/^\"//'|sed 's/\"$//'`
                ;;

        # 
        # Check for other switches
        #
        -*) # capture other command line switches
                OTHER_ARGS="$1 $OTHER_ARGS"
                ;;

        #
        # Catch file names
        #
	*)        #catch any non-processed arguments
                  PRINT_FILE="`echo $1|sed 's/^\"//'|sed 's/\"$//'` $PRINT_FILE"
                  ;;
    esac
    
    shift
    count=$(($count - 1))
done

#
# Let's take a minute to update the log file with some goodies
#

echo "Running Print Script: $0"            >> $LOGFILE
echo " Current script path: $CURRPATH"     >> $LOGFILE
echo "     Current OS Name: $OS_NAME"      >> $LOGFILE
echo "    System Data/Time: `date`"        >> $LOGFILE
echo "  configuration file: $CONFIG_FILE"  >> $LOGFILE
echo "         print files: $PRINT_FILE"   >> $LOGFILE
echo "     other arguments: $OTHER_ARGS"   >> $LOGFILE
echo "" >> $LOGFILE
echo "   Value of 'whoami': `whoami`"      >> $LOGFILE
echo "   Value of   LOGIN : $LOGIN"        >> $LOGFILE
echo "   Value of LOGNAME : $LOGNAME"      >> $LOGFILE
echo "   Value of     'id': `id`"          >> $LOGFILE        
echo "" >> $LOGFILE
echo "Dump of the first 10 lines of the report..." >> $LOGFILE
echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv" >> $LOGFILE

head -10 $PRINT_FILE >> $LOGFILE

echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" >> $LOGFILE
echo "" >> $LOGFILE

#
# OK, now process the config file if we have one
#

if [ "$CONFIG_FILE" != "" ]
then
    PROCESS_CONFIG "$CONFIG_FILE"
fi

#
# default format if one wasn't specified
#

#
# ### Remove per Steve's request as part of Bug #1299 fix
#
# if [ "$FORMAT" = "" ]
# then
#  FORMAT="MPAGE"
# fi


#
# Do not spool file if print mode is KEEP
#

if [ "$MODE" = "KEEP" ]
then
    echo "appx_print script is exiting early since MODE was KEEP" >> $LOGFILE
    exit
fi

#
# Now, we call a function to generate print spooler specific
# arguments based on the general settings we have.
#

LP_CMD="`echo $APPX_LP_CMD|cut -f 1 -d \ |sed 's/^.*\///'`"

if [ "$LP_CMD" = "lp" ]
then
    BUILD_LP_OPTIONS
elif [ "$LP_CMD" = "lpr" ]
then
    BUILD_LPR_OPTIONS
elif [ "$LP_CMD" = "ulp" ]
then
    BUILD_ULP_OPTIONS
fi    

echo "     Spooler Options: $LP_OPTIONS" >> $LOGFILE
echo "" >> $LOGFILE

#
# Now check for a filter script to use when formatting the report
# for the target printer.  We will first check in the "filter/"
# directory if it exists under the location of this script.  If
# we don't find a filter there that we need, then we will look for
# a default filter in the "filters/ASI/" directory.
#

FILTER=""

if [ "$FORMAT" != "" ]
then

    echo "-format=$FORMAT, checking for a filter script..." >> $LOGFILE

    if [ -d "$CURRPATH/filters" ]  # Does the filters/ directory exist?
    then
        if [ -x "$CURRPATH/filters/$FORMAT" ]
        then
            FILTER="$CURRPATH/filters/$FORMAT"
        else
            echo "    Filter $CURRPATH/filters/$FORMAT not found..." >> $LOGFILE

            if [ -d "$CURRPATH/filters/ASI" -a -x "$CURRPATH/filters/ASI/$FORMAT" ]
            then
                FILTER="$CURRPATH/filters/ASI/$FORMAT"
            else
            # Bug 2030: No text filter is supplied, so don't log an error
            if [ "$FORMAT" != "TEXT" ]
            then
             echo "    Filter $CURRPATH/filters/ASI/$FORMAT not found..." >> LOGFILE$
            fi 
          fi 
        fi
    else
        echo "    Filter directory $CURRPATH/filters/ does not exist!" >> $LOGFILE
    fi    

    if [ -z "$FILTER" ]
    then
        echo "No valid filter script found!" >> $LOGFILE
    else
        echo "        Using Filter: $FILTER" >>$LOGFILE
    fi
fi

# 
# Now assemble the command:  note that this "lp" command should
# be identical to those produced by Appx prior to release 2.0
#

for FILE in $PRINT_FILE
do
    while [ $COPIES -gt 0 ]
    do
        echo >> $LOGFILE 
        echo "## Final Invocation of $APPX_LP_CMD:">> $LOGFILE

        if [ "$FILTER" = "" ]
        then
            echo "$APPX_LP_CMD $LP_OPTIONS $FORM_CTL $PRINTER_CTL $FILE" >>$LOGFILE
                   $APPX_LP_CMD $LP_OPTIONS $FORM_CTL $PRINTER_CTL $FILE
        else
            echo "cat $FILE | $FILTER $FORM_CTL | $APPX_LP_CMD $LP_OPTIONS $PRINTER_CTL" >>$LOGFILE
                   cat $FILE | $FILTER $FORM_CTL | $APPX_LP_CMD $LP_OPTIONS $PRINTER_CTL            
        fi

	COPIES=`expr $COPIES - 1`
    done
done

#
# OK, we seem to be done.  Clean up the left over files as needed
#

echo "" >> $LOGFILE
echo "The Disposition was set to $DISPOSITION" >> $LOGFILE

if [ "$DISPOSITION" = "SCRATCH" ]
then
    sleep 2

    if [ -n "$PRINT_FILE" ]
    then
	if [ "$LP_CMD" = "ulp" ]
	then
	    echo "    Using ULP, not removing $PRINT_FILE" >> $LOGFILE
	else
	    echo "    Removing $PRINT_FILE" >> $LOGFILE
	    rm -f $PRINT_FILE	# if user specified SCRATCH, delete it
	fi    
    fi

    if [ -n "$CONFIG_FILE" ]
    then
        echo "    Removing $CONFIG_FILE" >> $LOGFILE
        rm -f $CONFIG_FILE 	# and any config file.
    fi
else
    echo "    Not removing Print or Config files" >> $LOGFILE
fi

echo "" >> $LOGFILE
echo "$0 script completed" >> $LOGFILE 
echo "============================================================================" >> $LOGFILE
  
#+###########################################################################
#+ Modification History
#+
#+ DATE      BY   Description
#+ --------  ---  ---------------------------------------------------------
#+ 11/13/93  KAD  Initial Creation
#+ 07/26/94  BHW  Modified to run under Bourne shell (instead of Korn
#+                Shell) for portability.  No loss of functionality, but
#+                some of the readability was sacrificed.  Many external
#+                utilities had to be used to compensate for the shell
#+                "downgrade."
#+ 07/26/94  BHW  Forced shell functions to spawn subshells to maintain
#+                positional parameters under HP-UX 8.0.  Now returning
#+                values from subshells through a clever (yet awkward)
#+                system of echos and evals.
#+ 09/20/94  BHW  First pass at multiple copies and scratching. ECR 2495
#+ 01/09/96  PAT  removed "eval `(...)`" construction, for latest hp & AIX. 
#+                releases.   Currently accepts only two input parameters:
#+                configuration filename, followed by print filename.
#+ 06/17/96  PAT  disabled default logging; delete configuration file.
#+ 08/01/96  PAT  reenabled /tmp/appx_print.last, with umask of 00; line 277   
#+ 08/13/98  PAT  additional logfile tracking  
#+ 12/14/99  KAD  Commented out 'whoami' line
#+ 03/21/01  PHB  Rewrite to implement linux lpr and filter scripts
#+ 03/21/01  PHB  Now works with lp, lpr, and ulp spoolers, only one script!
#+ 12/29/03  PHB  Now not removing print file for ULP.  ULP will remove it.
#+ 09/10/04  PHB  Bug #1299 - Removed MPAGE as default FILTER 
#+###########################################################################
