Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-01-2010, 07:42 AM   #1
LQ Newbie
Registered: Dec 2004
Posts: 12

Rep: Reputation: 1
UDEV rule not running a command


I have a UDEV rule below that maps a symlink from a specific usb device and 'Should' run a command.

The symlink part is fine but it does not appear to run the command when I plug the device in.

I can run the command "/usr/local/bin/my_command" from the shell fine.

mount /dev/myusbstick_1 /media/TMPUSB && cryptsetup luksOpen /dev/md5 md5_crypt --key-file=/media/TMPUSB/key && vgscan && vgchange -ay && mount -a && umount /media/TMPUSB
What am I missing. I have tried +x in owner,group and other.

By the way what does UDEV run as, I assumned +x on ROOT as that is the owner should be enough.
Old 08-02-2010, 04:34 AM   #2
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
I presume that the one line code is your my_command script.
As it is of the form :

command1 && command2 && command3 && ...

if one of the command fails the others will not be executed.
So maybe, when your script is launched by udev, that is what happens.
To know if it is the case and what command fails, you can modify your script like that :
if ! command1;then
    echo "Error executing command1 whith error $?" > logfilename
if ! command2;then
    echo "Error executing command2 whith error $?" >> logfilename
Or redirecting the standard output and standard error of the commands :
echo "Executing command1" > logfilename
if ! command1 &>> logfilename;then
    echo "Error executing command1 whith error $?" >> logfilename
echo "Executing command2" >> logfilename
if ! command2 &>> logfilename;then
    echo "Error executing command2 whith error $?" >> logfilename
So you will see what happens when udev runs the script.
Old 08-02-2010, 05:59 AM   #3
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
berbae's advice to get your command to do some logging is good. It might help to post your command here. One possible gotcha is that the $PATH environment variable may not be set to a sane value; try setting it to a sane value or using full paths on commands so $PATH is not used.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
udev rule executes command, wont add device node DigiLogik Linux - General 0 05-21-2009 05:19 PM
First UDEV Rule, Not quite there ... orbit Slackware 7 02-22-2009 10:08 PM
udev rule: need help DPenguin Linux - Hardware 0 08-04-2008 07:29 PM
Udev Rule Help Please Toods Slackware 1 11-23-2007 08:55 AM
need help with udev rule hussam Linux - Software 2 12-05-2006 03:30 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:40 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration