LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   problem with UDEV rules (https://www.linuxquestions.org/questions/red-hat-31/problem-with-udev-rules-655009/)

ukrishnanps 07-10-2008 11:50 PM

problem with UDEV rules
 
Hi ,
i wrote a new rule for detecting a USB drive(thump drive) connected and automatically create a file in USB drive connected. The rule which i wrote is given below.

KERNEL="sd[a-z][0-9]",SYMLINK="My_USB",RUN+="/usr/bin/script.sh"

when i connected the USB drive, the symbolic name got created . but the script is not getting executed.

The script i wrote is as follows.

#!/bin/sh
echo "Hii"
mount /dev/My_USB usb
cd usb
touch ff.txt
cd ..
umount /dev/My_USB


Why 'RUN+' command is not working...? is there any problem in my script file? If i am running this script seperately it's working fine.

I am using RED HAT enterprise edition 4 and kernal version 2.6.20.14

Please help...

Vit77 07-11-2008 12:49 AM

Are there SerialATA or SCSI hard drives in your box?
It could be the reason, because My_USB became a link to the HDD already.

ukrishnanps 07-11-2008 01:10 AM

i have SCSI hard disk in my system .. I am able to create the symbolic name My_USB and if i am running the script seperately, i am able to perform the operation using the same symbolic link. That means link is created properly right? Only when i am trying to invoke the script through RUN+=RUN+="/usr/bin/script.sh", the required action is not taking place.

pinniped 07-11-2008 01:22 AM

How do you know your script isn't being executed? You are not recording any information in a meaningful way (stdout is redirected to /dev/null). Try touching a file in '/tmp' or something to give you an indication of what's happening.

ukrishnanps 07-11-2008 01:59 AM

Problem with UDEV rules
 
Quote:

Originally Posted by pinniped (Post 3210854)
How do you know your script isn't being executed? You are not recording any information in a meaningful way (stdout is redirected to /dev/null). Try touching a file in '/tmp' or something to give you an indication of what's happening.

when i am running the script seperately after creating a symbolic link for USB drive, the required file is getting created in the USB drive(thump drive). But if i am trying to execute the script using the RUN+= option in the UDEV rule, the file is not getting created in the USB drive. from this i concluded that the script is not getting executed if i am tring with UDEV RUN+= option.

JZL240I-U 07-14-2008 03:09 AM

As Vit77 already wrote, udev doesn't like double links. I'd suggest to try the script from the udev rule without the "mount" and "umount" commands.


All times are GMT -5. The time now is 07:55 AM.