From owner-doc-jp@jp.freebsd.org  Thu Aug 29 17:56:51 1996
Received: by mail.jp.freebsd.org (8.7.3+2.6Wbeta5/8.7.3) id RAA03241
	Thu, 29 Aug 1996 17:56:51 +0900 (JST)
Received: by mail.jp.freebsd.org (8.7.3+2.6Wbeta5/8.7.3) with SMTP id RAA03227
	for <doc-jp@jp.freebsd.org>; Thu, 29 Aug 1996 17:51:25 +0900 (JST)
Received: from iwasaki.sirim.my ([161.142.131.209]) by relay3.jaring.my (8.6.13/8.6.12) with SMTP id QAA13676; Thu, 29 Aug 1996 16:51:03 +0800
Message-ID: <32255AA6.1FBC@pc.jaring.my>
Date: Thu, 29 Aug 1996 16:53:58 +0800
From: Mitsuru IWASAKI <iwasaki@pc.jaring.my>
Organization: AISDEL; SIRIM
X-Mailer: Mozilla 3.0b7 (Win95; I)
MIME-Version: 1.0
To: doc-jp@jp.freebsd.org, kimura@netlab.is.tsukuba.ac.jp
References: <199608290720.QAA23590@fairy.netlab.is.tsukuba.ac.jp>
Content-Type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Reply-To: doc-jp@jp.freebsd.org
X-Distribute: distribute [version 2.1 (Alpha) patchlevel=19]
X-Sequence: doc-jp 665
Subject: [doc-jp 665] Re: printing.sgml [Aug-23-1996]
Errors-To: owner-doc-jp@jp.freebsd.org
Sender: owner-doc-jp@jp.freebsd.org

$B$$$o$5$-(J@$B<YKb(J^H^H$B=uB@Ea(J $B$G$9!#(J

Shigetomo Kimura wrote:
>   $BLZB<(J@$BC^GHBg3X$G$9!%(J
>    >>From: Masafumi NAKANE/$BCf:,2mJ8(J <max@sfc.wide.ad.jp>
>    >>Date: Thu, 29 Aug 1996 15:07:03 +0900
> 
>    >>$B!!$H$j$"$($:!"$Q$Q!<$C$H(J printing.sgml $B$N(J section 7.6.4 $B$r$d$C$F$_$^$7(J
>    >>$B$?!#(J sgml $B$8$c$J$/$F$9$_$^$;$s!#$G!"$"$/$^$G$b;29M$K$7$F$$$?$@$1$l$P$H(J
>    >>$B$$$&$3$H$J$N$G!"86J8$b;D$7$F$"$j$^$9!#(J
>   $B$*<j?t$r$*$+$1$7$F$*$j$^$9!%$A$g$C$HC<Kv$+$iN%$l$F$$$?$iLu$,$G$-$F$$(J
> $B$k$H$O!%46N^$b$N$G$9!%8f6(NOK\Ev$K46<U$7$F$*$j$^$9!%$*0~MM$G!$@dK>;k$7(J
> $B$F$$$?(J8$B7nCf40@.$NEt$j$,8+$($F$-$?$h$&$J5$$,$7$^$9!%(J

$B$h$+$C$?$G$9!#$G$-$k$H$3$m$^$G4hD%$j$^$7$g$&(J!
$B$\$/$b!"(J7.6.5.1. Quick and Dirty Printer Accounting
$B$N$H$3$m$r!"Ck5Y$_$H$+$N5Y$_;~4V$rMxMQ$7$F$6!<$C$H$d$C$D$1$A$c$$$^$7$?$s(J
$B$G(J
$B;29M$K$7$F$/$@$5$$!#(J
$BK]Lu$N<A$O(J....$BJ9$+$J$$$G$/$@$5$$!#$^$"!"2?$bL5$$$h$j(J
$B$A$g$C$H$OLrN)$D(J ($B:.Mp$9$k(J?)$B$H;W$$$^$9!#(J

$B$3$3$+$i$3$3$+$i$3$3$+$i$3$3$+$i$3$3$+$i$3$3$+$i$3$3$+$i$3$3$+$i$3$3$+$i(J

7.6.5.1. Quick and Dirty Printer Accounting

FreeBSD $B$K$O4JC1$JDj4|E*(J accounting $B$G$9$0$K%;%C%H%"%C%W$G$-$k(J 
2$B$D$N%W%m%0%i%`$,IUB0$7$F$$$^$9!#$=$l$i$O!"(Jlpf: a Text Filter $B$N@a$G(J
$B=R$Y$i$l$F$$$k%F%-%9%H!&%U%#%k%?$G$"$k(J lpf $B$H!"%W%j%s%?$N(J accounting 
$B%U%!%$%k$+$i%(%s%H%j$r=8$a$F9g7W$9$k%W%m%0%i%`$G$"$k(J pac $B$G$9!#(J

FreeBSD comes with two programs that can get you set up with simple
periodic
accounting right away. They are the text filter lpf, described in
section lpf: a
Text Filter , and pac, a program to gather and total entries from
printer
accounting files.

filters ( Filters ) $B$N(J $B@a$G=R$Y$i$l$F$$$k$h$&$K!"(JLPD $B$O(J text $B$HJQ49%U%#(J
$B%k%?$r(J
$B%U%#%k%?!&%3%^%s%I%i%$%s$G;H$&(J accounting file $B$NL>A0$H0l=o$K5/F0$7$^(J
$B$9!#(J
$B%U%#%k%?$O$3$N0z?t$r!"(Jaccounting file $B%(%s%H%j$N=q$-9~$_@h$rCN$k$?$a$K(J
$B;HMQ$G$-$^$9!#$3$N%U%!%$%k$NL>A0$O(J /etc/printcap $B$K$"$k(J af capability $B$+(J
$B$i(J
$B$/$k$b$N$G$"$j!"@dBP%Q%9$H$7$F;XDj$5$l$F$$$J$1$l$P%9%W!<%j%s%0!&%G%#%l%/(J
$B%H%j(J
$B$+$i$NAjBP%Q%9$H$J$j$^$9!#(J

As mentioned in the section on filters ( Filters ), LPD starts the text
and the
conversion filters with the name of the accounting file to use on the
filter
command line. The filters can use this argument to know where to write
an
accounting file entry. The name of this file comes from the af
capability in
/etc/printcap, and if not specified as an absolute path, is relative to
the
spooling directory.

LPD $B$O(J lpf $B$r%Z!<%8I}$HD9$5$N0z?t(J (pw $B$H(J pl capabilities $B$+$i(J) $B$H6&$K(J
$B5/F0$7$^$9!##l#p#f(J $B$O$3$l$i$N0z?t$r;f$N;HMQKg?t$r7hDj$9$k$?$a$K;HMQ(J
$B$7$^$9!#%W%j%s%?$K%U%!%$%k$rAw$C$?8e!"(Jaccounting $B%(%s%H%j$r(J accounting
$B%U%!%$%k$X=q$-9~$_$^$9!#%(%s%H%j$O<!$N$h$&$J$b$N$G$9(J:

LPD starts lpf with page width and length arguments (from the pw and pl
capabilities). lpf uses these arguments to determine how much paper will
be used.
After sending the file to the printer, it then writes an accounting
entry in the
accounting file. The entries look like this: 

        2.00 rose:andy
        3.00 rose:kelly
        3.00 orchid:mary
        5.00 orchid:mary
        2.00 orchid:zhang

lpf $B$O(J logic built $B$J%U%!%$%k!&%m%C%-%s%0$r;}$?$:!"$=$7$F(J2$B$D$N(J lpf $B$,F1(J
$B$8(J
$B%U%!%$%k$KF1;~$K=q$-9~$_$r9T$C$?$i8_$$$N%(%s%H%j$rGK2u$9$k$+$b(J
$B$7$l$J$$$?$a!"%W%j%s%?Kh$KJL!9$N(J accounting $B%U%!%$%k$r;HMQ$9$k$Y$-$G$9!#(J
$B%W%j%s%?Kh$K(J accounting $B%U%!%$%k$NJ,N%$KJ]81$r$+$1$k4JC1$JJ}K!$O(J
af=acct $B$r(J /etc/printcap $B$K@_Dj$9$k;v$G$9!#$=$7$F!"3F(J accounting $B%U%!%$(J
$B%k$O(J
acct $B$H$$$&%U%!%$%kL>$G%W%j%s%?MQ$N%9%W!<%j%s%0!&%G%#%l%/%H%j$KCV$+$l$k(J
$B$G$7$g$&!#(J

You should use a separate accounting file for each printer, as lpf has
no file
locking logic built into it, and two lpfs might corrupt each other's
entries if
they were to write to the same file at the same time. A easy way to
insure a
separate accounting file for each printer is to use af=acct in
/etc/printcap.
Then, each accounting file will be in the spooling directory for a
printer, in a
file named acct.

$B0u:~$9$k%f!<%6$K2]6b$9$k=`Hw$,$G$-$?$i!"(Jpac $B%W%m%0%i%`$r<B9T$7$F$/$@$5(J
$B$$!#(J
collect $B$7$?$$%W%j%s%?MQ$N%9%W!<%j%s%0!&%G%#%l%/%H%j$X9T$-!"(Jpac $B$H%?%$%W(J
$B$7$F2<$5$$!#(J
$B<!$N$h$&$J(J dollar-centric $B%5%^%j$,F@$i$l$k$G$7$g$&!#(J

When you are ready to charge users for printouts, run the pac program.
Just
change to the spooling directory for the printer you want to collect on
and type
pac. You will get a dollar-centric summary like the following: 


  Login               pages/feet   runs    price
orchid:kelly                5.00    1   $  0.10
orchid:mary                31.00    3   $  0.62
orchid:zhang                9.00    1   $  0.18
rose:andy                   2.00    1   $  0.04
rose:kelly                177.00  104   $  3.54
rose:mary                  87.00   32   $  1.74
rose:root                  26.00   12   $  0.52

total                     337.00  154   $  6.74


$B$3$l$i$O(J pac $B$,4|BT$9$k0z?t$G$9(J:

These are the arguments pac expects: 

-Pprinter

     $B%5%^%i%$%:$9$k%W%j%s%?!#$3$N%*%W%7%g%s$O(J /etc/printcap $B$N(J af
capability $B$K(J
     $B@dBP%Q%9$,B8:_$9$k>l9g$N$_M-8z$G$9!#(J

     Which printer to summarize. This option works only if there is an
absolute
     path in the af capability in /etc/printcap.

-c

     $B%f!<%6L>$N%"%k%U%!%Y%C%H=g$NBe$o$j$K=PNO$r(J cost $B$N=g$K%=!<%H!#(J

     Sort the output by cost instead of alphabetically by user name.

-m

     accounting $B%U%!%$%k$N%[%9%HL>$rL5;k$7$^$9!#$3$N%*%W%7%g%s$G!"%[%9%H(J
alpha $B$N(J
     $B%f!<%6(J smith $B$O!"%[%9%H(J gamma $B$N%f!<%6(J smith $B$HF10l$H$_$J$5$l$^$9!#(J
$B$3$N(J
     $B%*%W%7%g%s$,L5$$$$>l9g!"$=$l$i$O0[$J$k%f!<%6$H$J$j$^$9!#(J
     
     Ignore host name in the accounting files. With this option, user
smith on
     host alpha is the same user smith on host gamma. Without, they are
different
     users.

-pprice

     /etc/printcap $B$N(Jpc capability $B$+$i$N(J price $B$^$?$O(J 2 $B%;%s%H(J ($B%G%U%)(J
$B%k%H(J) $B$N(J
     $BBe$o$j$K%Z!<%8$^$?$O(J foot $BEv$?$j$N2]6b$r7W;;$7$^$9!#IbF0>.?tE@$G(J
price$B$r(J
     $B;XDj$G$-$^$9!#(J

     Compute charges with price dollars per page or per foot instead of
the price
     from the pc capability in /etc/printcap, or two cents (the
default). You can
     specify price as a floating point number.

-r

     $B%=!<%H=g$r5U$K$7$^$9!#(J

     Reverse the sort order.

-s

     accounting $B%5%^%j!&%U%!%$%k$r:n@.$7!"(Jaccounting $B%U%!%$%k$r@Z$j<N$F(J
$B$^$9!#(J

     Make an accounting summary file and truncate the accounting file.

names...

     $BM?$($i$l$?%f!<%6L>$@$1$N(J accounting $B>pJs$r(J print $B$7$^$9!#(J

     Print accounting information for the given user names only.

pac $B$,@8@.$7$?%G%U%)%k%H$N%5%^%j$G$O!"?'!9$J%[%9%H$+$i$N%f!<%6Kh$N0u:~$5(J
$B$l$?(J
$B%Z!<%8?t$,$o$+$j$^$9!#$b$7$"$J$?$N%5%$%H$G%[%9%H$,LdBj$H$J$i$J$$$J$i(J ($B%f(J
$B!<%6$O(J
$B$I$N%[%9%H$G$b;HMQ$G$-$k$N$G(J) $B!"(Jpac -m $B$r<B9T$7$F<!$N$h$&$J%5%^%j$r:n@.(J
$B$7$F2<$5$$!#(J

In the default summary that pac produces, you see the number of pages
printed by
each user from various hosts. If, at your site, host does not matter
(because
users can use any host), run pac -m, to produce the following summary: 


  Login               pages/feet   runs    price
andy                        2.00    1   $  0.04
kelly                     182.00  105   $  3.64
mary                      118.00   35   $  2.36
root                       26.00   12   $  0.52
zhang                       9.00    1   $  0.18

total                     337.00  154   $  6.74


dollar amount due $B$r7W;;$9$k$?$a$K!"(J pac $B$O(J/etc/printcap $B%U%!%$%k$N(J pc
capability 
$B$r;HMQ$7$^$9(J ($B%G%U%)%k%H$O!"%Z!<%8C10L(J 200 $B$^$?$O(J 2 $B%;%s%H$G$9(J) $B!#$3$N(J
capability $B$K(J
$B0u:~$K2]6b$7$?$$%Z!<%8C10L$^$?$O(J foot $BC10L$N(J price $B$r(Jhundreths of cents
$B$G(J
$B;XDj$7$F$/$@$5$$!#(J-p $B%*%W%7%g%sIU$-$G(J pac $B$r<B9TCN$?>l9g!"$3$NCM$rL58z$K(J
$B$9$k(J
$B$3$H$,$G$-$^$9!#(J-p $B%*%W%7%g%s$XM?$($kC10L$O!"(Jhundredths of cents $B$G$O$J(J
$B$/(J 
dollars $B$G$9!#Nc$($P!"(J

To compute the dollar amount due, pac uses the pc capability in the
/etc/printcap
file (default of 200, or 2 cents per page). Specify, in hundreths of
cents, the
price per page or per foot you want to charge for printouts in this
capability.
You can override this value when you run pac with the -p option. The
units for
the -p option are in dollars, though, not hundredths of cents. For
example, 

     pac -p1.50

$B$O!"3F%Z!<%8(J 1 $B%I%k(J 50 $B%;%s%H$K$7$^$9!#$3$N%*%W%7%g%s$r;HMQ$7$F!"9S2T$.(J
$B$9$k;v$,(J
$BK\Ev$K$G$-$k$N$G$9!#(J

makes each page cost one dollar and fifty cents. You can really rake in
the
profits by using this option.

$B:G8e$K!"(Jpac -s $B$N<B9T$O%5%^%j>pJs$r%W%j%s%?$N(J accounting $B%U%!%$%k$HF1$8(J
$B%U%!%$%kL>$N(J
$B%5%^%j(J accounting $B%U%!%$%k$X3JG<$7$^$9$,!"%U%!%$%kL>$K(J _sum $B$,DI2C$5$l$^(J
$B$9!#$=$7$F(J
accounting $B%U%!%$%k$r@Z$j<N$F$^$9!#(Jpac $B$r:F<B9T$7$?>l9g!"9g7W$r3+;O$9$k(J
$B$?$a$K(J
$B%5%^%j!&%U%!%$%k$r:FEYFI$_9~$_!"$=$7$F@55,$N(J accounting $B%U%!%$%k$+$i$N>p(J
$BJs$rDI2C(J
$B$7$^$9!#(J

Finally, running pac -s will save the summary information in a summary
accounting
file, which is named the same as the printer's accounting file, but with
_sum
appended to the name. It then truncates the accounting file. When you
run pac
again, it rereads the summary file to get starting totals, then adds
information
from the regular accounting file.


$B$3$3$^$G$3$3$^$G$3$3$^$G$3$3$^$G$3$3$^$G$3$3$^$G$3$3$^$G$3$3$^$G$3$3$^$G(J

$B$G$o$G$o!#(J
-- 
                               o
                         [=]   O
                        (.~.)_P
+==================oooO==( )//Oooo=================+
|Mitsuru Iwasaki                                   |
|15A-1-3, Scots Tower, MONT' KIARA CONDOMINIUM,    |
|Jalan 1/70C, Off Bikit Kiara, 50480 Kuala Lumpur  |
|TEL: 03-253-8579                    _/_/_/    _/  |
|FAX: 03-253-8579                   _/_/_/    _/   |
|e-mail: iwasaki@sirim.my(OFFICE)  _/  _/ _/ _/    |
|        iwasaki@pc.jaring.my(HOME)                |
|        JAA03673@niftyserve.or.jp(JAPAN)          |
+==================================================+
