A while back I learned about this website, Apple Config Code Lookup, when I was building my first info grab script for an inventory. I have since evolved that script into a full Info Viewer (inventory is done via MunkiReport-PHP). One thing I was always missing was the output from the Apple Config Code Lookup; since I am migrating most of my shell scripts to Python, I figured I might as well add it. I am also learning to modularize my scripts whenever possible as well. This has made things really easy to combine scripts or call them from others. I also wanted to be able to call this script if fed a serial as well. Here we go.

The old shell script I have is this:

curl -s http://support-sp.apple.com/sp/product?cc=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}' | cut -c 9-) | sed 's|.*<configCode>\(.*\)</configCode>.*|\1|' | tr ',' '.'

To me..that’s very ugly and very foreign as I am still learning RegEx + sed