getting U3 serial number on Mac OS X
ambassador at fourthworld.com
Sun Dec 17 20:21:42 CST 2006
Phil Davis wrote:
> I did a little more homework and decided to make one small change. The
> system_profiler option (parameter) as originally coded doesn't work as
> expected on my PowerPC Mac running 10.3.9; it has to be entered in an
> older format to work. But more important, a parameter that asks
> system_profiler for USB-only info makes it run between 2x and 7x
> faster (roughly) depending on the state of the USB drive
Thanks Phil! Good work. It's one thing to craft a useful handler, and
another to refine and optimize it.
That's a very helpful contribution to the community.
Richard Gaskin Managing Editor, revJournal
Rev tips, tutorials and more: http://www.revJournal.com
> So here's the updated function, ready for action on PowerPC or Intel Mac:
> function u3SerialNumbers
> # Return the serial numbers of all U3 drives currently known to the OS.
> switch the platform
> case "Win32"
> return $U3_DEVICE_SERIAL
> case "MacOS"
> set the itemDelimiter to "."
> if the systemVersion < 10 then return empty -- system is not OS X
> -- prep
> put 0 into x
> put empty into tSerialNumberList
> put shell("system_profiler SPUSBDataType") into tProfile
> -- get U3 serial numbers
> put lineOffset("U3 smart drive:",tProfile) into xStart
> if xStart = 0 then exit repeat -- no U3 drive was found
> 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
> return empty
> end switch
> end u3SerialNumbers
More information about the use-livecode