Results 1 to 10 of 43

Thread: howto run a script when a USB device is pluged in

Threaded View

  1. #1
    Join Date
    Oct 2006
    Beans
    149

    howto run a script when a USB device is pluged in

    This explains how you could run a script made by you (say /usr/local/my_script) when you plug a specific USB device.

    1. First run lsusb to identify your device. Example:
    $lsusb
    Bus 004 Device 001: ID 0000:0000
    Bus 003 Device 001: ID 040a:0576 Kodak Co.
    Bus 002 Device 001: ID 0000:0000
    Bus 001 Device 001: ID 0000:0000

    2. After doing this you know that
    - the vendor ID of your device is 040a
    - the product ID of your device is 0576

    3. Now is time to create your UDEV rule:
    Code:
    sudo nano /etc/udev/rules.d/85-my_rule.rules
    4. And add the text
    Code:
    ACTION=="add", SUBSYSTEM=="usb_device", SYSFS{idVendor}=="040a", SYSFS{idProduct}=="0576", RUN+="/usr/local/my_script"
    Explanation:
    When the usb_device product identified as 0576 of vendor 040a is added, run /usr/local/my_script
    Note that '==' and "!=" are comparators, while = and += are assingments
    Last edited by Carlos Santiago; July 18th, 2007 at 02:49 PM.

Bookmarks

Posting Permissions

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