I am currently working on a project to run a program written in C when a USB device is connected. Is this possible with udev rules?
I am currently running Hello World script when I connect my device. However, he runs it more than once.
Current path: /etc/udev/rules.d/98-local.rules
Current Rule:
SUBSYSTEMS == "usb", ACTION == "add", RUN + = "/USR/local/ben/USB.sh"
Script path: /usr/local/bin/USB.sh
Script:
#!/bin/bash echo 'Hello World!' >>"/home/<username>/Desktop/udev.out" exit
I tried something like this to run the executable:
#!/bin/bash usr/games/blackjack exit
typing usr / games / blackjack works in the terminal, however it does not work when a USB device is inserted. However, I know that the script works, because I combined them into one file, and the hi world was created.
I also tried to run the executable from my user account, as shown below:
SUBSYSTEMS=="usb", ACTION=='add", RUN+="/bin/su tyler -c '/usr/local/bin/USB.sh'"
However, this does not work either.
Is this a problem with device privileges or is it just impossible to run an executable file?
* note: I read the explanations of the udev rule at http://reactivated.net/writing_udev_rules.html .