Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to create a udev rule to unlock my computer when I connect my phone by USB. I could not find that that rule was being ran and so I tried a much simpler rule. This is the rule (anonymized) :

KERNEL=="sd?1", ATTRS{idVendor}=="****", ATTRS{idProduct}=="****", SYMLINK+="phone", RUN+="touch /home/user/udev.touch"

I know that the rule is running because the link phone -> sdc1 is being created but the file is not being created. Are there security setting that I have to enable for the file to run an external program?

share|improve this question
    
Have you tried using the full path? /usr/bin/touch –  arrange Oct 10 '11 at 20:31
    
I just tried it. That is now working. Why does udev not search the path? and does that mean that I will have to have the full path for every command in the script that I want to run as well? –  Andrew Redd Oct 10 '11 at 20:49
add comment

2 Answers

up vote 0 down vote accepted

You must use full path in the RUN key because (man udev)

If no absolute path is given, the program is expected to live in /lib/udev, otherwise the absolute path must be specified. Program name and arguments are separated by spaces. Single quotes can be used to specify arguments with spaces.

Nevertheless the (bash) script itself should behave as normal, that is you don't need to specify the path.

share|improve this answer
    
It seems that only the very simplest of commands works. Scripts don't run either even when the entire path is given –  Andrew Redd Oct 10 '11 at 22:03
    
Please post the full script you're trying to run. Be aware that the script is run as root, not as a regular user. –  arrange Oct 11 '11 at 7:56
    
I found I had a bad path to bash. The script on add works now but the remove rule does not run. I'll ask as a different question. –  Andrew Redd Oct 11 '11 at 22:41
add comment

I've had this issue as well, and I can confirm as of 12.04 you need to specify the full bash path and full bash script for the RUN command to work.

Not a big deal, just nice to know when your bashing your head against the wall. Har har!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.