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.

0 Answers0