Please don't mark this as duplicate as this is a different question!
I am trying to run a script whenever a pendrive is connected to my system. I followed this and this question And it is working but still there are some problems.
This is my udev rules file:
ACTION=="add", ATTRS{idVendor}=="8564", ATTRS{idProduct}=="1000", RUN+="/usr/local/my_script.sh"
and this is my script:
#!
/bin/bash
env > /tmp/env.out
cp -r /media/*device-name*/* ~/test/
I have 2 questions:
1.Whenver I plug in my usb device script is executed because a file env.out is generated in /tmp but the data from usb device is not copied in to test directory, if I run the script manually then it works fine! Why??
2.How can make my rules file more general so that it will work for any USB device which is connected without knowing its ID?
My idea behind this is to copy all the data from connected USB device to my computer automatically, when it is connected.
Thanks in advanced!