LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   udev rule to invoke a script (https://www.linuxquestions.org/questions/linux-newbie-8/udev-rule-to-invoke-a-script-871612/)

vinaytp 03-29-2011 12:08 AM

udev rule to invoke a script
 
Dear All,

I am not good at writing udev rules. I am using RHEL 4.7, I would like to invoke a file install.sh which is in CDROM as soon as the CDROM is inserted.

How to go about it ?

Thanks

easuter 03-29-2011 05:54 AM

Hi,

I'm not sure that what you want to do is possible with a cdrom drive (but I may be wrong). CD drives, as far as I know, don't notify the operating system when the drive has been opened or closed, it's the operating system that has to continually poll the drive to see if anything has happened (on Linux this is what HAL does).

What you want to do is possible in the case of USB storage devices since plugging in a USB device generates a UDEV event that the OS can catch; VectorLinux uses this method to automount pen-drives (see http://code.google.com/p/vl-hot/).

Perhaps you may have more luck reading HAL's documentation, it might be possible to create a policy that can do what you need (see here for some examples on creating policies: https://wiki.archlinux.org/index.php/HAL).

Hope this helps.

jschiwal 03-29-2011 06:35 AM

Ubuntu utilizes an autorun feature for CDROMs, which might provide a model. However I would like you to consider not doing this at all. Auto-run is extremely dangerous. About as dangerous as being a snake charmer. You are trying to add autorun to a linux distro, when MS is removing that feature. That should tell you something.

Also, an install script should not be launched from a udev rule. Scripts launched with RUN+= need to be short and quick.
Since they run in the background, the install script can't expect input or print output unless it's to a log file, or using "logger".


All times are GMT -5. The time now is 03:24 PM.