disk serial numbaer

Post

Posted
Rating:
#1 (In Topic #137)
Regular
sony is in the usergroup ‘Regular’
 Hello,
How to read the usb stick volume serial number?
Thank

Sony
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’
This is one way of doing it:-

Code

Public Sub Main()
'this sub uses the list of links in: /dev/disk/by-id/
'...which includes the device identity and serial number

Dim strDisk As String
Dim strLink As String
Dim strName As String
Dim strSerial As String

  For Each strDisk In Dir("/dev/disk/by-id", "usb-*", gb.Link)
    strLink = Stat("/dev/disk/by-id/" & strDisk).Link
    strLink = "/dev/" & Right(strLink, - RInStr(strLink, "/"))
    If Len(strLink) = 8
      strDisk = Mid(strDisk, InStr(strDisk, "_") + 1)
      strDisk = Mid(strDisk, 1, InStr(strDisk, "-") - 1)
      strName = Replace(Left(strDisk, RInStr(strDisk, "_")), "_", " ")    
      strSerial = Mid(strDisk, RInStr(strDisk, "_") + 1, InStr(strDisk, "-") - 1)
      Print strName & " serNo: " & strSerial
    Endif
  Next  

End

Or you could use the Linux command: lsusb -v   …which must be run as root.
This will give you access to more device information (e.g. idProduct, idVendor, iProduct, iSerial, USB class)
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
Here is another way of doing it. This works in Linux Mint but whether it will work in other distros is another matter.

Attachment

Image

(Click to enlarge)


EDIT: - It does not work on the Raspberry Pi
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
sony is in the usergroup ‘Regular’
 Thank you very much

Sony
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
jornmo is in the usergroup ‘Regular’
Hey Sony!

I like your TVs and loudspeakers  :lol:  

Sorry, I just could not help myself ;) I have a very dry sense of humour…  Welcome (back) to the forums!  :ugeek:

Online now: No Back to the top
1 guest and 0 members have just viewed this.