Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the ' suggestion' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say. suggestion
Authored by: ctierney on Aug 28, '08 11:58:52AM
I discovered that system_profiler on 10.3 has no detailLevel -3, but you can specify only the datatypes you're interested in which might also be quicker:
computername=`/usr/sbin/system_profiler SPSoftwareDataType | sed -ne '/Computer/ s/.* //p'`
serialnumber=`/usr/sbin/system_profiler SPHardwareDataType | sed -ne '/Serial/ s/.* //p'`
Panther users could then run this via cron.

[ Reply to This | # ] suggestion
Authored by: lugal on Aug 28, '08 04:18:38PM

We've used a similar sort of home-grown tracker for a few years now. I haven't had the chance yet to compare the author's solution to ours, but I can report that our method for finding the serial number is faster than either the original code, or your improved version:

serialnumber=`ioreg -c "IOPlatformExpertDevice" | awk 'BEGIN{FS="\""}; /IOPlatformSerialNumber/ {print $4}'`

[ Reply to This | # ] suggestion
Authored by: patpro on Aug 28, '08 09:55:37PM

Nice one!

In fact there is so much room for improvement in that script :)


[ Reply to This | # ] suggestion
Authored by: engelby on Aug 29, '08 06:55:03PM

Indeed there is. This is actually a version 2 of my script. The first was much smaller than this, so this is a huge improvement over it. I know there is a lot more that could be done to it.

[ Reply to This | # ] suggestion
Authored by: ctierney on Aug 29, '08 06:59:46AM
That is a lot quicker! You can make it even faster by quitting awk when you find the serial number. On my mac ioreg -c 'IOPlatformExpertDevice' prints 407 lines of text, and the serial number is at the top in line 11 (profiling with time utility):
time ioreg -c 'IOPlatformExpertDevice' | awk -F\" '/IOPlatformSerialNumber/ {print $4; exit}'

[ Reply to This | # ]