This is the ubiqx binary tree and linked list library.
[Samba.git] / examples / printer-accounting / lp-acct
blob3fe45f877fd7e096b011ab61c286914ac93b2d57
1 #!/usr/bin/perl
3 # $Source: /data/src/mirror/cvs/samba/examples/printer-accounting/lp-acct,v $
4 # $Id: lp-acct,v 1.1 1996/07/23 03:30:56 samba-bugs Exp $
6 # 0 == stdin == docuement
7 # 1 == stdout == printer
8 # 2 == stderr == logging
10 # Regular, with no redirection
13 umask(002);
15 # -w132 -l66 -i0 -n pkelly -h master.fcp.oypi.com /var/log/lp-acct
16 require "getopts.pl";
17 &Getopts("w:l:i:n:h:");
19 chomp($date = `date '+%Y-%m-%d.%T'`);
21 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
22 $atime,$mtime,$ctime,$blksize,$blocks)
23 = stat(STDIN);
25 $cnt = 0;
26 while (sysread(STDIN, $buf, 10240)) {
27 print $buf;
28 $cnt += ($buf =~ /^L/g);
31 $acct = shift;
32 if (open(ACCT, ">>$acct")) {
33 print ACCT "$date $opt_n $opt_h $size $cnt\n";
34 close(ACCT);
35 } else {
36 warn "Err: Can't account for it ($!)\n";
37 warn "Log: $date $opt_n $opt_h $size $cnt\n";