I have some trouble with running script from udev rule. It works normal if I will run it from terminal, but one command doesn't work when udev rule run this script.
Udev rule: /etc/udev/rules.d/84-test-rule.rules
ACTION=="remove", RUN+="/bin/bash -c '/usr/bin/sblock.sh >> /home/username/udev_test_log.txt'"
Script: /usr/bin/sblock.sh
#!/bin/bash
echo Hello, its script from udev udev_test_log.txt # this line wors normal
xdg-screensaver lock # but screen not block
I expect, that my system will blocks every time I remove usb-flash (I have planned to add some properties of my usb-drive later). But after removing flash I have only line in file udev_test_log.txt
.
System -- kubuntu 16.04
#!/bun/bash
or#!/bin/bash
? If you have a shebang line (#!/bin/bash
) and have made the script executable, why are you running withbash -c
? More importantly, what fails? Is theecho Hello
line printed? What were you expecting to happen and what actually happens? – terdon Apr 11 '17 at 11:59