You are not logged in.

#1 2010-11-29 18:27:40

Mr. Alex
Member
Registered: 2010-08-26
Posts: 623

How to perform a command automatically on turning printer on?

I need the system to do

# modprobe usblp && sleep 5 && modprobe -r usblp

automatically when I turn on HP laserjet 1018. How can I do it?

Offline

#2 2010-11-29 18:36:04

Dogmeat
Member
From: Slovak Republic
Registered: 2009-02-24
Posts: 193

Re: How to perform a command automatically on turning printer on?

Why? I have HP LaserJet 1018 and it works fine without doing this (I've blacklisted usblp module in /etc/rc.conf).

Offline

#3 2010-11-30 20:48:39

Mr. Alex
Member
Registered: 2010-08-26
Posts: 623

Re: How to perform a command automatically on turning printer on?

Well, I have

MODULES=(fuse !usblp)

in rc.conf and I need to do that command when I turn on the printer and the PC is already running. Otherwise it won't print.

Offline

#4 2010-11-30 21:40:26

owain
Member
Registered: 2009-08-24
Posts: 251

Re: How to perform a command automatically on turning printer on?

The answer to the question is with udev rules.  However, there should be a solution to your problem rather than the workaround with usblp.  I seem to remember the same problem, with a LaserJet 1005 (which I think is very similar to the 1018), around the time of a major CUPS upgrade.  The issue was with permissions on /dev/bus/usb/XXX/XXX, which needed 0664 permissions and root:lp ownership.  The following saved as /etc/udev/rules.d/10-printer.rules solved it for me:

SUBSYSTEMS=="usb", SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="1317", GROUP:="lp", MODE:="0664"

Offline

#5 2010-12-04 20:48:41

Mr. Alex
Member
Registered: 2010-08-26
Posts: 623

Re: How to perform a command automatically on turning printer on?

OK, so I added this to /etc/udev/rules.d/11-hplj10xx.rules and now it looks like this:

ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="0517", RUN+="/sbin/foo2zjs-loadfw 1000 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="1317", RUN+="/sbin/foo2zjs-loadfw 1005 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="4117", RUN+="/sbin/foo2zjs-loadfw 1018 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="2b17", RUN+="/sbin/foo2zjs-loadfw 1020 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="3d17", RUN+="/sbin/foo2zjs-loadfw P1005 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="3e17", RUN+="/sbin/foo2zjs-loadfw P1006 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="4817", RUN+="/sbin/foo2zjs-loadfw P1007 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="4917", RUN+="/sbin/foo2zjs-loadfw P1008 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="3f17", RUN+="/sbin/foo2zjs-loadfw P1505 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="4017", RUN+="/sbin/foo2zjs-loadfw P1505n $tempnode"

SUBSYSTEMS=="usb", SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="1317", GROUP:="lp", MODE:="0664"

but when I turn on the printer, it doesn't do what it should do... Is there anything else I should do?

Last edited by Mr. Alex (2010-12-04 20:48:56)

Offline

#6 2010-12-04 21:59:03

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: How to perform a command automatically on turning printer on?

You are a member of the lp group?


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#7 2010-12-09 20:25:41

Mr. Alex
Member
Registered: 2010-08-26
Posts: 623

Re: How to perform a command automatically on turning printer on?

Yep.

$ groups
disk lp wheel log network video audio optical storage users lpadmin

Offline

#8 2010-12-09 22:05:25

kwirkie
Member
Registered: 2010-01-09
Posts: 15

Re: How to perform a command automatically on turning printer on?

It appears you are using the idProduct of the 1005 model. From that the rest of the file it appears that you should use SYSFS{idProduct}=="4117" for the HP LaserJet 1018. You can double check the product id by using 'lsusb' with the printer plugged in, the printer entry will have be "ID 03f0:xxxx", where xxxx is the product id.

Last edited by kwirkie (2010-12-09 22:15:31)

Offline

#9 2010-12-12 20:51:34

Mr. Alex
Member
Registered: 2010-08-26
Posts: 623

Re: How to perform a command automatically on turning printer on?

Yes, the id is correct.

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 03f0:4117 Hewlett-Packard LaserJet 1018
...

The file now looks like

ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="0517", RUN+="/sbin/foo2zjs-loadfw 1000 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="1317", RUN+="/sbin/foo2zjs-loadfw 1005 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="4117", RUN+="/sbin/foo2zjs-loadfw 1018 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="2b17", RUN+="/sbin/foo2zjs-loadfw 1020 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="3d17", RUN+="/sbin/foo2zjs-loadfw P1005 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="3e17", RUN+="/sbin/foo2zjs-loadfw P1006 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="4817", RUN+="/sbin/foo2zjs-loadfw P1007 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="4917", RUN+="/sbin/foo2zjs-loadfw P1008 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="3f17", RUN+="/sbin/foo2zjs-loadfw P1505 $tempnode"
ACTION=="add", KERNEL=="lp*", SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0",     \
    ATTRS{idProduct}=="4017", RUN+="/sbin/foo2zjs-loadfw P1505n $tempnode"

SUBSYSTEMS=="usb", SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="4117", GROUP:="lp", MODE:="0664"

Then I rebooted the PC and now the printer still doesn't work without that command in the first post.

Last edited by Mr. Alex (2010-12-12 20:52:07)

Offline

#10 2010-12-13 11:30:12

owain
Member
Registered: 2009-08-24
Posts: 251

Re: How to perform a command automatically on turning printer on?

Maybe put that rule into a separate lower-numbered file, so that the permissions are changed before the foo2zjs-loadfw command is called?

Offline

#11 2010-12-13 15:13:05

Mr. Alex
Member
Registered: 2010-08-26
Posts: 623

Re: How to perform a command automatically on turning printer on?

What file should it be?

Offline

#12 2010-12-13 18:26:37

owain
Member
Registered: 2009-08-24
Posts: 251

Re: How to perform a command automatically on turning printer on?

/etc/udev/rules.d/10-hp1018.rules, for example - the file are processed in numerical order

Offline

#13 2010-12-16 21:39:26

Mr. Alex
Member
Registered: 2010-08-26
Posts: 623

Re: How to perform a command automatically on turning printer on?

# ls -l /etc/udev/rules.d/10-hp1018.rules
-rw-rw-rw- 1 root root 95 Dec 17 00:31 /etc/udev/rules.d/10-hp1018.rules

# cat /etc/udev/rules.d/10-hp1018.rules
SUBSYSTEMS=="usb", SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="4117", GROUP:="lp", MODE:="0664"

Is this correct?
And it doesn't help... Still the printer doesn't print after turning it on.

Offline

Board footer

Powered by FluxBB