PDA

View Full Version : Use udevadm to test for printer offline?



Eric_Lee
March 7th, 2014, 10:45 PM
I want to test that a printer on a parallel port is available, that sending a file to it will not fail because it is offline, off, cover open, out of paper.

My reading of the udevadm manpage suggests that it might be used for this but it isn't clear how, or maybe my reading is too hopeful.

Is this the right approach; is there a better way?

Ubuntu: 12.04.4

The printer is on /dev/lp0, can be written to, and is defined for udev:

$ udevadm info --name=/dev/lp0 --query=all
P: /devices/pnp0/00:07/printer/lp0
N: lp0
E: DEVNAME=/dev/lp0
E: DEVPATH=/devices/pnp0/00:07/printer/lp0
E: MAJOR=6
E: MINOR=0
E: SUBSYSTEM=printer
E: TAGS=:udev-configure-printer:
E: UDEV_LOG=3
E: USEC_INITIALIZED=8006083
and:

$ udevadm info -a -n /dev/lp0
looking at device '/devices/pnp0/00:07/printer/lp0':
KERNEL=="lp0"
SUBSYSTEM=="printer"
DRIVER==""

looking at parent device '/devices/pnp0/00:07':
KERNELS=="00:07"
SUBSYSTEMS=="pnp"
DRIVERS=="parport_pc"
ATTRS{id}=="PNP0400"

looking at parent device '/devices/pnp0':
KERNELS=="pnp0"
SUBSYSTEMS==""
DRIVERS==""