How can I detect an unmounted USB device?

Discussion in 'Mac Programming' started by Sciuriware, Dec 1, 2015.

  1. Sciuriware macrumors regular

    Sciuriware

    Joined:
    Jan 4, 2014
    Location:
    Gelderland
    #1
    Hello all,
    after I umount/eject a USB disk or stick, I can no longer see it.
    However I would like to check if somebody has physically disconnected the device
    by taking it out or disconnecting the cable.
    I found that DiskUtility can 'see' such devices.
    Is there any way, e.g. from a shell command, to detect their presence?
    Thanks in advance.
    ;JOOP!
     
  2. MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #2
    You could always try a diskutil list command to see if it shows up there. I am thinking if it lists the device in the gui not mounted as I have seen before it most likely will on the command line as well, never tried it so not positive on this though.
     
  3. Sciuriware thread starter macrumors regular

    Sciuriware

    Joined:
    Jan 4, 2014
    Location:
    Gelderland
    #3
    That's a good suggestion.
    Only a bit clumsy to filter the info identifying the drive among all others.
    Btw.: I program in JAVA and it's no problem to spawn the diskutil command and catch its output.
    ;JOOP!
     

Share This Page