Date: Tue, 20 Jun 2000 09:36:12 +0200
From: Francesc Guasch <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: LPRng: Accounting for HP4050n

Here you can download a perl script that does accounting from
an HP4050n to a database.

http://www.etsetb.upc.es/~frankie/acc-0.01.tar.gz

I have it working in a production site with 3500 students.



contents of the README FILE

1.- DISCLAIMER

##    This package is free software; you can redistribute it
##    and/or modify it under the same terms as Perl itself.

2.- DESCRIPTION

This script does accounting from an HP4050n printer. It reads
and stores data from a database.

Sometimes it makes the printer go crazy and you have to switch
it off and on or stop lpd. It looks like recently it has improved
this a little.

It is very slow.

Currently is version 0.01

3.- HOW IT WORKS

I couldn't manage to make a real filter so I talk right
to the printer in postscript PCL and everything I could.

The script reads the job and looks for the login name. It connects
to the database looking for the user, if the user doesn't exists it
quits. If the user exists it looks if the user still has quota and
prints the job.

At the end of the job the printed pages are stored in the user quota
in the database.



4.- INSTALLATION

        1.- Copy the executable acc.pl anywhere and remember the place.
        2.- Modify your printcap file so there is a filter like this:
  
        hp4050n|lp5:
        :lp=/dev/null
        :if=/root/acc.pl
        :sd=/var/spool/lpd/hp4050n
        :lf=/usr/adm/lpd-errs

        3.- Copy and modify the configuration file to /etc, make sure
                to do a chmod 600 and it's owned by daemon or the user of
                your lpd daemon.


        4.- Make a table in a database, mine is like this:

        
        CREATE TABLE printer_quotas (
          login char(20) DEFAULT '' NOT NULL,
          printer char(20) DEFAULT '' NOT NULL,
          quota int(11),
          current int(11),
          total int(11) DEFAULT '0' NOT NULL, # That's not mandatory
          UNIQUE login (login,printer)        # That's not mandatory but
        );                                    #   I'd keep it

        5.- Make sure you can connect to the database from the host you have
        the printer.

        6.- Restart lpd

        7.- Have fun



5.- CHANGING SOURCES

        The script is very simple and straightforward if you had written it.
        If you want to change things maybe you're interested in these 
        subroutines:

        * allowed : checks the database, if your tables are different you
                can change the SQL statement here.


        * update_quota : updates the database

        * init_printer : I call this method all the time, slow but works

        * wait_end : looks the status of the printer, this is the one that
                is SLOW

        * count : query the printer for its counter



6.- IF SOMETHING GOES WRONG

        - Make sure the user you're testing is in the database
        - Maybe your printer is not the same as mine and so it doesn't work,
          HP printers are good, but accounting is hard and different.
        - Mail me, I'll do my best. I must warn you it works for me like this.



7.- TODO

        - message to the user if runs out of quota.
        - message to the admin if a user is not in the database.



8.- AUTHOR

        Francesc Guasch-Ortiz   ,[EMAIL PROTECTED]





-- 
 - frankie -

-----------------------------------------------------------------------------
If you need help, send email to [EMAIL PROTECTED] (or lprng-requests
or lprng-digest-requests) with the word 'help' in the body.  For the impatient,
to subscribe to a list with name LIST,  send mail to [EMAIL PROTECTED]
with:                           | example:
subscribe LIST <mailaddr>       |  subscribe lprng-digest [EMAIL PROTECTED]
unsubscribe LIST <mailaddr>     |  unsubscribe lprng [EMAIL PROTECTED]

If you have major problems,  send email to [EMAIL PROTECTED] with the word
LPRNGLIST in the SUBJECT line.
-----------------------------------------------------------------------------

Reply via email to