Writing a script to simulate the hot plug for linux USB

Writing a script to simulate the hot plug for linux USB


Here is a script you can use ...

Give name myusbmonitor

# to run $>myusbmonitor 1 / $>myusbmonitor 0

#!/bin/sh
#Description: A prototype script to demonstrate insertion/removal any usb device \
using udev frame work of linux #
#Note: Use this script when you have following lines to \
/etc/udev/rules.d/50-udev.rules #
# ##Added by Manjunathan Padua
ACTION=="add", SUBSYSTEM=="usb_device", RUN+="/sbin/myusbmonitor 0"
ACTION=="remove", SUBSYSTEM=="usb_device", RUN+="/sbin/myusbmonitor 1"
#

if [ $1 -eq "0" ]; then
echo "usb was inserted into the PC " >> /tmp/usb ; #log the usb found event
else
echo "usb was removed from the PC" >> /tmp/usb ; #log the usb removal event
fi

Comments

Popular posts from this blog

8051 Development Setup:MIDE-51 Installation

Nokia dot Matrix LCD Interfacing with 89c51( 8051 core)