How to detect programatically if a USB device is is plugged-in / plugged out?
Hi all,
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. Franc |
Hi
I suppose you could use the "lsusb" command, which then references to the /dev/sd... device. Cheers |
I think you can do this with udev rules. See this link:
http://www.reactivated.net/writing_u...l#external-run |
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 11:26 AM. |