My goal is to run a Python script when inserting a USB flash drive. I wrote a udev rule and a shell script that is called in this rule.
udev rule: /etc/udev/rules.d/10-usb.rules
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", RUN+="/home/Hypotheron/Desktop/script.sh"
script.sh:
#!/bin/sh
echo 'Hello, world.' > /home/Hypotheron/Desktop/foo.txt
The first line of my Python file:
I also executed the following commands:
chmod +x job.py
chmod +x script.sh
In script.sh, when a line entry in foo.txt is uncommented, the foo.txt file is created each time a flash drive is inserted.
When I comment on this line and uncomment the line in which the Python file runs, it does not work.
Running the terminal script.sh through both works, but when you insert a flash drive, only the foo.txt file works.
Any help would be appreciated.
source
share