Automatic script for usb not working in ubuntu

Akash Yadav
@akash-4IhYJo โ€ข Oct 27, 2024

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 .

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Abhishek Rawal

    @abhishek-fg9tRh • Mar 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 ๐Ÿ˜€

  • Akash Yadav

    @akash-4IhYJo • Mar 16, 2015

    It worked fine ๐Ÿ˜ though it seems notify-send doesn't work with root .

    Thanks a lot #-Link-Snipped-# .