Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to when I plug an usb device to my laptop, a script will be run just one time. So I use the udev rules system in UBUNTU 12.04. I wrote the below udev rule:

ACTION=="add", SUBSYSTEMS=="usb", RUN+="/home/hossein/Desktop/test".

The below commands is written in the test script:

#!/bin/bash
echo Hello >> /home/hossein/Desktop/file.txt

my problem is that when I attach a usb device, about 13 times the word Hello is written in the file.txt while I just expect one time occurrence of Hello. What's the reason?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You need to make your udev rule more specific, try adding this to your rule:

ENV{DEVTYPE}=="usb_device"

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.