CrazyEngineers
  • Automatic script for usb not working in ubuntu

    Akash Yadav

    Member

    Updated: Oct 27, 2024
    Views: 1.2K
    My objective is to run the script automatically when usb-dongle is inserted . I looked into other links in google for the same but just can't get it work . Script is running fine manually but doesn't run when usb dongle is inserted .
    Below are the details for the same . Please someone suggest what am i missing ?


    1.
    meher@meher-Compaq-620:~$ lsusb
    Bus 002 Device 011: ID 12d1:14db Huawei Technologies Co., Ltd.


    2. Script is
    meher@meher-Compaq-620:~$ ls -lrt ~/mtsdongle.sh
    -rwxrwxrwx 1 root root 92 Mar 11 22:27 /home/meher/mtsdongle.sh

    meher@meher-Compaq-620:~$ cat ~/mtsdongle.sh
    #! /bin/sh
    notify-send "****** <MTS DONGLE INSERTED> *****"
    env > /tmp/env.out


    3. rules is
    meher@meher-Compaq-620:/etc/udev/rules.d$ pwd
    /etc/udev/rules.d


    meher@meher-Compaq-620:/etc/udev/rules.d$ ls -lrt
    -rwxrwxrwx 1 root root 116 Mar 11 22:32 77-mts.rules

    meher@meher-Compaq-620:/etc/udev/rules.d$ cat 77-mts.rules
    ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", ATTR{idProduct}=="14db", RUN+="/home/meher/mtsdongle.sh"

    Tagging #-Link-Snipped-# for help .
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Abhishek Rawal

    MemberMar 16, 2015

    Everything looks good, it should work. But sometimes minute things creates havoc.
    Have you tried restarting udev service ?
    sudo etc/init.d/udev restart
    and also don't forget to make shell script an executable
    chmod 755 /home/meher/mtsdongle.sh

    If still problem exists, do comment. We'll help you out 😀
    Are you sure? This action cannot be undone.
    Cancel
  • Akash Yadav

    MemberMar 16, 2015

    It worked fine 😁 though it seems notify-send doesn't work with root .

    Thanks a lot #-Link-Snipped-# .
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register