LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


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

Rep: Reputation: 1
UDEV rule not running a command


Hello

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

Code:
BUS=="usb",SYSFS{serial}=="1111111111111111111111111111",SYMLINK+="myusbstick_%n",RUN+="/usr/local/bin/my_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.

Code:
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
berbae
Member
 
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 :
Code:
if ! command1;then
    echo "Error executing command1 whith error $?" > logfilename
    exit
fi
if ! command2;then
    echo "Error executing command2 whith error $?" >> logfilename
    exit
fi
...
Or redirecting the standard output and standard error of the commands :
Code:
echo "Executing command1" > logfilename
if ! command1 &>> logfilename;then
    echo "Error executing command1 whith error $?" >> logfilename
    exit
fi
echo "Executing command2" >> logfilename
if ! command2 &>> logfilename;then
    echo "Error executing command2 whith error $?" >> logfilename
    exit
fi
...
So you will see what happens when udev runs the script.
 
Old 08-02-2010, 05:59 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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.
 
  


Reply

Tags
udev



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:29 PM.

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