Click to See Complete Forum and Search --> : How to detect a USB pendriver?


Daniel Patrick
01-30-2006, 10:01 AM
I'd like to detect when a pendriver is connected and execute some specific application (e.g. Konqueror). Some distribution show an icon in the desktop.
Thanks a lot.
Daniel Patrick

tecknophreak
01-30-2006, 01:05 PM
Depends on what version of what distro you have. At home I'm running FC4 and if I'm in KDE it'll automatically do this.

Otherwise, I guess you could always just check the /proc/bus/usb directories and files.

Daniel Patrick
01-30-2006, 02:37 PM
Thanks a lot, using the lsusb and /proc/bus/usb I can check if a pendriver is connected.
But now, after detected it, how can I mount it?
#mount <device> /mnt/pendriver

Is it possible to find where is the device?
I'm on Debian - Kernel 2.4.27.

Thanks a lot
Daniel Patrick

tecknophreak
01-30-2006, 02:46 PM
What programming language?

Daniel Patrick
01-30-2006, 03:01 PM
The language can be C or C++.
I think the problem is to find if the device is on /dev/sda1, /dev/ttyUBS0 or etc ...

Thanks a lot

bwkaz
01-30-2006, 08:09 PM
I'm on Debian - Kernel 2.4.27. Upgrade to kernel 2.6.X, and use hotplug/udev. That's what hotplug and udev are for -- generating user-space notifications of device insertion and removal.