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
15 # -w132 -l66 -i0 -n pkelly -h master.fcp.oypi.com /var/log/lp-acct
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)
26 while (sysread(STDIN
, $buf, 10240)) {
28 $cnt += ($buf =~ /^L/g);
32 if (open(ACCT
, ">>$acct")) {
33 print ACCT
"$date $opt_n $opt_h $size $cnt\n";
36 warn "Err: Can't account for it ($!)\n";
37 warn "Log: $date $opt_n $opt_h $size $cnt\n";