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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-07-2014, 01:03 PM
|
#1
|
Member
Registered: Jan 2004
Posts: 537
Rep:
|
udev rules not working?
I want to run a script when usb flash device is connected in ubuntu 13.10, this is the /etc/udev/rules.d/91.test.rule:
Quote:
KERNEL=="sdc", ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0951", ATTRS{idProduct}=="1607", RUN+="/home/user/tmp/test.sh"
|
this is the test.sh:
Quote:
#! /bin/sh
if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
echo ${DEVICE} >> /var/log/backuptousbdrive.log
fi
|
But this is not working?
|
|
|
02-08-2014, 06:42 AM
|
#2
|
Senior Member
Registered: Feb 2003
Distribution: debian
Posts: 4,137
|
What user would that launched process run as? nobody? And does it have write permissions to /var/log/? Perhaps another method of verifying if it works or not.
|
|
|
02-08-2014, 11:51 AM
|
#3
|
Member
Registered: Jan 2004
Posts: 537
Original Poster
Rep:
|
Thanks for reply, the problem is not with the permission but the with the rule itself, i tested with other programs like this one:
Quote:
KERNEL=="sdc", ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0951", ATTRS{idProduct}=="1607", RUN+="/usr/bin/bluefish"
|
The rule should launch the bluefish that can be as user or root no problem but not working.
|
|
|
02-09-2014, 09:59 AM
|
#4
|
Senior Member
Registered: Feb 2003
Distribution: debian
Posts: 4,137
|
According to the manpage.
--- Starting daemons and other long running processes is not appropriate for udev; the forked processes, detached or not, will be unconditionally killed after the event handling has finished. ---
So whatever it does will likely persist for as long as it takes to create the /dev/ names for the device. Or I could be wrong. You'll likely need to setup a daemon to lauch whatever application and the RUN would pass some form of communication to that daemon to do something (like create a file and if a file exists the daemon launches an application and removes the file to avoid duplication of efforts).
In the case of a GUI application you'll need the magic cookie and DISPLAY and XAUTHORITY vars set for the user who launches that application. AKA the .Xauthority file depending on distro and configuration. The user who launches X has those configured already because it launched X. Any other user wanting to share the X session has to do that manually, unless the display manager handles that process.
|
|
|
All times are GMT -5. The time now is 03:29 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|