II : Print-Job accounting

2007-12-25 8:58:00

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\ / ) | (\ / | / \

Comments

Got something to say?

You must be logged in to post a comment.