How to get 'pagecount' in the Terminal

kandombe

Registered
Hi,

I'd like to get the 'pagecount' from a network printer using a Unix command from the Terminal.
In pure Unix machines this is easily achieved by using 'npadmin', but I haven't been able to properly compile it in Darwin due to a conflict with the 'getopt()' function of the GNU_LIBRARY.
The other thing I have tried is to put the following PostScript code into a file and send it to the printer:

#!
statusdict begin pagecount == end flush

I have tried to send it to the printer both with the 'lp' and the 'lpr' commands but I get no response.

Any ideas? Thanks.
 
After you type "configure" when building npadmin, this simple fix will allow you to compile: Edit the 'Makefile' that is produced after running 'configure' and look for a line that reads:

DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I.

and add an extra flag so it now reads:

DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I. -D__GNU_LIBRARY__

npadmin should now compile for you without any problems. I tested this on Mac OS X 10.4.4 with g++ 4.0.1, and npadmin 0.10 from http://freshmeat.net/projects/npadmin/
 
Thanks macbri for your answer. The trick worked pretty well. Although I still get some warnings, the code compiled and run. The warnings were:

gcc -DHAVE_CONFIG_H -I. -I. -I. -D__GNU_LIBRARY__ -g -O2 -c getopt.c
getopt.c:72: warning: could not use precompiled header '/usr/include/unistd-gcc3.p', because:
getopt.c:72: warning: '/usr/include/unistd.h' has different date than in precomp
gcc -DHAVE_CONFIG_H -I. -I. -I. -D__GNU_LIBRARY__ -g -O2 -c getopt1.c
c++ -DHAVE_CONFIG_H -I. -I. -I. -D__GNU_LIBRARY__ -g -O2 -c snmpsock.C
snmpsock.C: In function `void* receiver(void*)':
snmpsock.C:92: warning: invalid conversion from `unsigned int*' to `int*'


In any case, I'm afraid that 'npadmin' doesn't fully support my printers (HP LaserJet 2300 and 2550n), because the --pagecount, as well as other options, don't work. They give a 'option not supported on this printer type' message.

I will keep on exploring the PostScript way.
 
Hi,

I finally found a way using directly SNMP. I downloaded 'ucd-snmp' from http://net-snmp.sourceforge.net/ and it compiled perfectly.
Then, I just needed to use 'snmpwalk' to locate the address of the 'pagecount' value and it was as simple as using 'snmpget' with that address (43.10.2.1.4.1.1)
 
Back
Top