in reply to Re^4: USB interface
in thread USB interface

On my Windows box, I can detect the insertion of a USB stick within 2 seconds of it happening with this one liner:
perl -le "while(1) {print \"USB stick inserted\" if -d 'E:/';sleep 2}"
I guess something similar can be applied to linux.

Cheers,
Rob

Replies are listed 'Best First'.
Re^6: USB interface
by Corion (Patriarch) on Jun 15, 2009 at 06:47 UTC

    Why use polling when the WMI tells you? The synopsis of DBD::WMI shows an example that detects when a drive gets added/removed. Alternatively, I think I would hook into the dialog that asks "What to do with this device?" whenever a new device is added. But this is all Windows and the question seems to be for Linux...

Re^6: USB interface
by ikegami (Patriarch) on Jun 15, 2009 at 17:15 UTC
    I don't think that's sufficient. You'd have to check more than one drive letter, and I think you're able to mount a USB drive without assigning a letter to it. (I'm not at my Windows system to test it.)