Find the answer to your Linux question:
Results 1 to 3 of 3
I'm trying to run a script when a sd card is inserted into the drive. my udev rules are as follows: BUS=="usb", KERNEL=="sd*", SYSFS{serial}=="058F63356336", NAME="sdcard", RUN+="/bin/mount /dev/sdcard" BUS=="usb", KERNEL=="sd*", SYSFS{serial}=="058F63356336", ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! spg666's Avatar
    Join Date
    Dec 2008
    Location
    UK
    Posts
    24

    run script from udev


    I'm trying to run a script when a sd card is inserted into the drive.
    my udev rules are as follows:

    BUS=="usb", KERNEL=="sd*", SYSFS{serial}=="058F63356336", NAME="sdcard", RUN+="/bin/mount /dev/sdcard"
    BUS=="usb", KERNEL=="sd*", SYSFS{serial}=="058F63356336", OPTIONS+="last_rule", RUN+="/home/user/test"

    The first line works, naming the device as "sdcard" and mounting it in the correct location. The second line should run a simple script to write a file with some text in it. If I run the script it works so I'm assuming it's not being done by udev but I done know why.

    Just for info, my intention is to run an encryption program when the sdcard is inserted.

  2. #2
    Linux Engineer Segfault's Avatar
    Join Date
    Jun 2008
    Location
    Acadiana
    Posts
    877
    Probably your script is not using full paths to commands, udev is not running in your user environment.

  3. #3
    Just Joined! spg666's Avatar
    Join Date
    Dec 2008
    Location
    UK
    Posts
    24
    well I solved it in the end, turns out that I needed to include this line in my script

    export Display=:0.0

    before running a program with a GUI eg kwrite in the above example
    Last edited by spg666; 10-01-2010 at 01:13 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •