[英]run program when usb connected to raspberry pi
I'm trying to run a program when I plug USB to my Raspberry Pi 3 model B.当我将 USB 插入我的 Raspberry Pi 3 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我在下面引用了两个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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.