[Gambas-user] Usb

Kende Krisztián nemh at ...2007...
Tue Jul 30 11:54:36 CEST 2013


> >> is it possible to list all the usb devices on a system?
> >>
> > Yeah, the lsusb command is your friend.
> >
> 
> I should have said usb drive I was thinking using dev some how
> 

No problem, I use this for pendrives:

Dim item, dev, name As String

For Each item In Dir("/dev/disk/by-id", "usb-*", gb.Link)

  dev = Stat("/dev/disk/by-id/" & item).Link
  dev = "/dev/" & Right(dev, - RInStr(dev, "/"))

  If Len(dev) = 8

    name = Right(item, -4)
    name = Left(name, RInStr(name, "_"))

    Print dev & " " & Replace(name, "_", " ")

  Endif

Next

This not work with HDDs.




More information about the User mailing list