1

I am trying to automatically copy the *.png images from a folder of my usb flash drive once its plugged into my linux workstation.

I have written the bash script to do it and created the /etc/udev/rules.d/test.rules file to add it as a rule.

Now when I run the command sudo udevadm trigger in the terminal the images from the folder gets copied into the required folder, but when I unplug and insert the usb flash drive, the script is not triggered automatically (which I expect to happen).

The bash file contains the following script :

#! /bin/bash

cd /media/user/flashDriveName/folderName

for f in *.png
do 
   cp -v "$f" /home/user/Desktop/toBePastedFolder/
done

#END

The test.rules file contains :

KERNELS=="usb", SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{idProduct}=="wxyz", ATTRS{idVendor}=="abcd", ATTRS{serial}=="diahsduahd4e81378",ATTRS{version}=="2.00", RUN+="/home/user/Desktop/bashFile.sh"

How to overcome this problem? I am working in Intel processor based workstation running Ubuntu 16.04 distro. Thanks in advance for the answers.

  • I have tried many methods, even [this](https://askubuntu.com/questions/401390/running-a-script-on-connecting-usb-device). So please donot mark this as duplicate. – Arvind Sharma Aug 03 '17 at 10:24
  • Possible issue, the script is run before the drive get mounted. Check this post https://askubuntu.com/q/646011/26246 – user.dz Sep 17 '17 at 11:19

0 Answers0