I'm trying to run a program when I plug USB to my Raspberry Pi 3 model B.
I referenced below two https://hackaday.com/2009/09/18/how-to-write-udev-rules/ https://unix.stackexchange.com/questions/65891/how-to-execute-a-shellscript-when-i-plug-in-a-usb-device
sudo nano /etc/udev/rules.d/81-usb.rules
KERNEL=="sda1", RUN+="echo Hello World > /home/pi/hello.txt"
sudo /etc/init.d/udev restart
I almost tried every variation, rebooted a lot, just in case I'm missing something. But nothing works.
Thanks for reading.
Thanks stark. Anyway I'm answering my own Question.
I changed it from
KERNEL=="sda1", RUN+="echo Hello World > /home/pi/hello.txt"
to
KERNEL=="sda1", RUN+="/home/pi/test.sh"
also did
chmod +x /home/pi/test.sh
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.