LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   usb dongle / udev-rule (https://www.linuxquestions.org/questions/linux-hardware-18/usb-dongle-udev-rule-942908/)

toredo 05-02-2012 07:29 AM

usb dongle / udev-rule
 
Hello,

I try to create a very simple kind of usb-dongle. Just a usb stick with one special file on it.

When the usb-stick is connected to the computer there should be a script executed. The same thing if someone removes the stick.

I tried and tried, but it didn't work.

I just created a file '/etc/udev/rules.d/10-dongle.rules' with the following content:
Code:

SUBSYSTEM=="usb", KERNEL=="sd?1", ATTR{idVendor}=="1307", ATTR{idProduct}=="0165", RUN+="date>>/tmp/out"
Has someone an idea?

best regards
toredo

catkin 05-02-2012 11:11 AM

Two doubts.

IDK if the RUN string can do redirection. You could try writing a script that does what your existing RUN string does and give the full path to it in the RUN string. For good measure give the full path to the date command in the script -- probably not necessary but does no harm. Might be useful to make the script log the $PATH value too.

IDK if the ? wildcard in KERNEL=="sd?1" is valid.

Apart from that, assuming you used udevadm info to get the listed attributes, it looks good.

toredo 05-02-2012 04:04 PM

Ok, now it works. I've got the attributes from the internet (every usb device should have a product- and vendorid), but i'll check them with udevadm.

I use now this line:
Code:

SUBSYSTEM=="usb", ATTR{idVendor}=="1307", ATTR{idProduct}=="0165", RUN+="/root/test.sh"
Thx for the fast help

Best regards
toredo


All times are GMT -5. The time now is 10:00 PM.