How to detect programatically if a USB device is is plugged-in / plugged out?
How can I programatically detect if any USB drive (say thump drive) is plugged-in or plugged out at any time?
Also get details on the device plugged-in?
Can I use udev rules to achieve this?
The goal is to get access to the contents within the program.
Thanks for your help.
I suppose you could use the "lsusb" command, which then references to the /dev/sd... device.
I think you can do this with udev rules. See this link:
Both method would work.
As you are using udev, you always know what will be the name of the device node in /dev.
Then this is ok (for shell scripts) :
[ -b /dev/sda ] && echo "sda present" || echo "sda not present"
|All times are GMT -5. The time now is 01:43 AM.|