title: Executing a shell script on a udev rule
body: <p>I am trying to execute a Java program on inserting a USB Flash Drive and pass the path of the USB Flash Drive as a parameter to my Java program. To achieve this, I have written a 'udev' rule in both '/etc/udev/rules.d' and '/lib/udev/rules.d' with the names '99-thumbdrive.rules' and '98-thumbdrive.rules'.</p>
  
  <p>The rule is as follows:</p>
  
  <pre><code>ACTION=="add", KERNEL=="sd?1", SUBSYSTEM=="usb", RUN="/home/nouman/Data/NSProj/shell.sh"
  </code></pre>
  
  <p>The 'shell.sh' file has been made executable by using 'sudo chmod +x shell.sh'</p>
  
  <p>When I insert my Flash Drive and run the command 'udevadm test /dev/bus/003/008', I see my rules being read.</p>
  
  <pre><code>read rules file: /lib/udev/rules.d/98-thumbdrive.rules
  read rules file: /etc/udev/rules.d/99-thumbdrive.rules
  </code></pre>
  
  <p>My shell.sh file is as follows</p>
  
  <pre><code>#!/bin/bash
  java USB
  </code></pre>
  
  <p>I have been trying this for a couple of days now and have read most of the posts online but am unable to run my script. Kindly help me out. </p>