SUMMARY II : Print-Job accounting

From: Manjeet_Singh (manjeet@cadence.com)
Date: Fri Mar 31 1995 - 04:44:27 CST


Hello Managers,

Here is a neat solution for getting a neat one-line output for
every print job. Thanks to Claude Charest (charest@CANR.Hydro.Qc.CA)
who provided me lot of help.

...manjeet

Solution :
--------

The trick is to modify your input filter and take advantage of temp file
created while printing. Check your printcap file and look for an entry
like ":if=". Add ":af=" entry also. See eg. below:

lw4|ps|PostScript:\
        :mx#0:sb:lp=/var/spool/lw4/.null:\
        :sd=/var/spool/lw4:\
        :sh:\
        :lf=/var/spool/lw4/log:\
        :of=/usr/lib/hpnp/hplj.of.sh:\
        :if=/usr/lib/hpnp/hplj.if.sh:\
        :af=/var/adm/lpacct:

Now make "/var/adm/lpacct" file world writable and add following lines
in your input filter (/usr/lib/hpnp/hplj.if.sh in this case) :

PATH="/usr/lib/hpnp:$PATH:/usr/ucb"
DATE=`date '+%d/%m/%y-%H%M'`
ACCT="/var/adm/lpacct"
tmp_file=`grep '^cf' lock`
file_name=`grep '^N' $tmp_file

if test "$ACCT" -a -w "$ACCT"
then
    echo -n "$LOGIN" >> $ACCT
    echo -n ' ' >> $ACCT
    echo -n "$HOST" >> $ACCT
    echo -n ' ' >> $ACCT
    echo -n "$DATE" >> $ACCT
    echo -n ' ' >> $ACCT
    echo -n "$file_name" >> $ACCT
    echo -n ' ' >> $ACCT
    echo "" >> $ACCT
fi

............................................................

#=====================================================================#
# The opinions expressed above are not those of Cadence Inc. #
# or a subsidiary thereof... #
# manjeet@Cadence.com #
#=====================================================================#

          \ o / __o __| \ / |__ o__ \ o /
              | /\ ___\o \o | o/ o/___ /\ |
            / \ | \ /) | ( \ /o\ / ) | (\ / | / \



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:21 CDT