1 | #! /bin/sh |
---|
2 | |
---|
3 | # This script was generously contributed by Jem E. Berkes. |
---|
4 | # It can't work as-is with PyKota, you first have to adapt it |
---|
5 | # and this may require some work on your part. |
---|
6 | |
---|
7 | # It is aimed at printers which support the PJL language, which |
---|
8 | # are plugged through a bidirectionnal parallel port. |
---|
9 | |
---|
10 | # Read what Jem has to say about it : |
---|
11 | |
---|
12 | # It seems that network sockets or some other control specific method is the |
---|
13 | # best way to query the printers. What I have is a bit (well, more than just |
---|
14 | # a bit) of a brute forced solution. However, it has been working for us for |
---|
15 | # about a month and only needs a bidirectional /dev/lp0 |
---|
16 | |
---|
17 | # I'm not at all happy about the sleep's I have in there. On occasion, there |
---|
18 | # are missing page counts in the log but since the * next * user to print |
---|
19 | # gets a good pagecount, the parser (a separate program) finds the |
---|
20 | # responsibility. |
---|
21 | # |
---|
22 | # If you find a way to improve what I have, please let me know. Note that |
---|
23 | # when this is invoked from printcap, it's expecting that the data coming it |
---|
24 | # at stdin is a pre-formatted print job (the Windows machines do that |
---|
25 | # anyway). |
---|
26 | |
---|
27 | # Copyright (C) 2003 Jem E. Berkes |
---|
28 | # jb2003@pc9.org |
---|
29 | # This script queries the HP LaserJet 1200 for pagecount, then prints a |
---|
30 | # pre-formatted job |
---|
31 | # Log format: DATE\tUSERNAME\tPRECOUNT |
---|
32 | |
---|
33 | PRINTDEV=/dev/lp0 |
---|
34 | LOGFILE=$SPOOL_DIR/pagelog |
---|
35 | |
---|
36 | echo -e "\33%-12345X@PJL\n@PJL INFO VARIABLES\n\33%-12345X" > $PRINTDEV |
---|
37 | sleep 1 |
---|
38 | cat $PRINTDEV > /dev/null |
---|
39 | echo -e "\33%-12345X@PJL\n@PJL INFO PAGECOUNT\n\33%-12345X" > $PRINTDEV |
---|
40 | sleep 1 |
---|
41 | PAGECOUNT=`cat $PRINTDEV | grep "^[0-9]"` |
---|
42 | USERID=`echo $1 | cut -b 3- | sed "s/@.*//"` |
---|
43 | echo -e "`date \"+%Y-%m-%d %H:%M:%S\"`\t$USERID\t$PAGECOUNT" >> $LOGFILE |
---|
44 | cat > $PRINTDEV |
---|
45 | |
---|