| 
            Last change
 on this file since 660 was             414, checked in by Herwig Bauernfeind, 16 years ago           | 
        
        
          | 
             
Samba 3.5.0: Initial import 
 
           | 
        
        
          | 
            File size:
            746 bytes
           | 
        
      
      
| Line |   | 
|---|
| 1 | #!/usr/bin/perl
 | 
|---|
| 2 | #
 | 
|---|
| 3 | # 0 == stdin  == docuement
 | 
|---|
| 4 | # 1 == stdout == printer
 | 
|---|
| 5 | # 2 == stderr == logging
 | 
|---|
| 6 | #
 | 
|---|
| 7 | # Regular, with no redirection
 | 
|---|
| 8 | #
 | 
|---|
| 9 | 
 | 
|---|
| 10 | umask(002);
 | 
|---|
| 11 | 
 | 
|---|
| 12 | # -w132 -l66 -i0 -n pkelly -h master.fcp.oypi.com /var/log/lp-acct
 | 
|---|
| 13 | require "getopts.pl";
 | 
|---|
| 14 | &Getopts("w:l:i:n:h:");
 | 
|---|
| 15 | 
 | 
|---|
| 16 | chomp($date = `date '+%Y-%m-%d.%T'`);
 | 
|---|
| 17 | 
 | 
|---|
| 18 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
 | 
|---|
| 19 |         $atime,$mtime,$ctime,$blksize,$blocks)
 | 
|---|
| 20 |  = stat(STDIN);
 | 
|---|
| 21 | 
 | 
|---|
| 22 | $cnt = 0;
 | 
|---|
| 23 | while (sysread(STDIN, $buf, 10240)) {
 | 
|---|
| 24 |         print $buf;
 | 
|---|
| 25 |         $cnt += ($buf =~ /^L/g);
 | 
|---|
| 26 | }
 | 
|---|
| 27 | 
 | 
|---|
| 28 | $acct = shift;
 | 
|---|
| 29 | if (open(ACCT, ">>$acct")) {
 | 
|---|
| 30 |         print ACCT "$date $opt_n $opt_h $size $cnt\n";
 | 
|---|
| 31 |         close(ACCT);
 | 
|---|
| 32 | } else {
 | 
|---|
| 33 |         warn "Err: Can't account for it ($!)\n";
 | 
|---|
| 34 |         warn "Log: $date $opt_n $opt_h $size $cnt\n";
 | 
|---|
| 35 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.