getting U3 serial number on Mac OS X

Phil Davis revdev at pdslabs.net
Sat Dec 16 02:22:41 EST 2006


Hi List,

I decided to find a way to get a U3 drive's serial number on Mac (OS X only). 
Sorry, I don't have a method for Linux but would welcome anyone's contribution 
in this regard.

Here's what I came up with:



function u3SerialNumbers
   # Return a return-delimited list of all U3 device serial
   # numbers currently known to the system.

   switch the platform

   case "Win32"
     return $U3_DEVICE_SERIAL
     break

   case "MacOS"
     set the itemDelimiter to "."
     if the systemVersion < 10 then return empty

     -- prep
     put 0 into x
     put empty into tSerialNumberList
     put shell("system_profiler -detailLevel mini") into tProfile

     -- get U3 serial numbers
     repeat
       put lineOffset("U3 smart drive:",tProfile) into xStart
       if xStart = 0 then exit repeat

       put lineOffset("Serial Number:",tProfile,xStart) + xStart into xSerNum
       put last word of line xSerNum of tProfile & cr after tSerialNumberList
       delete line 1 to xSerNum of tProfile
     end repeat

     delete last char of tSerialNumberList
     return tSerialNumberList
     break

   default
     return empty
     break
   end switch
end u3SerialNumbers


Thanks -
Phil Davis



More information about the Use-livecode mailing list