Extension Attribute to pull OS build number?

donmontalvo
Esteemed Contributor III

Ok, any script gurus here who can help us cobble together an Extension Attribute to capture and display the OS build number? Please point me to any existing method if I missed it. :)

Here's what we have:

$ system_profiler | grep "System Version: Mac OS X" | awk '{ print $6 $7 }'
2012-04-19 13:51:15.146 system_profiler[13331:60b] CFURLCreateWithString was passed this invalid URL string: '/System/Library/Image%20Capture/Devices/TWAINBridge.app' (a file system path instead of an URL string). The URL created will not work with most file URL functions. CFURLCreateWithFileSystemPath or CFURLCreateWithFileSystemPathRelativeToBase should be used instead.
10.7.3(11D50)

The very last part of the output is what we need...not sure what the goobleygook stuff is before it. Is there a better way to get the desired output (in this case "10.7.3(11D50)")? :)

TIA

Don

--
https://donmontalvo.com
2 ACCEPTED SOLUTIONS

nessts
Valued Contributor II

sw_vers ProductName: Mac OS X
ProductVersion: 10.7.3
BuildVersion: 11D50

View solution in original post

rockpapergoat
Contributor III

sw_vers -buildVersion

check the man page.

View solution in original post

4 REPLIES 4

nessts
Valued Contributor II

sw_vers ProductName: Mac OS X
ProductVersion: 10.7.3
BuildVersion: 11D50

rockpapergoat
Contributor III

sw_vers -buildVersion

check the man page.

mm2270
Legendary Contributor III

Yeah, 'sw_vers' is what i always use when looking to pull the OS and build info via a script. Forget system_profiler, too much overhead for just pulling that data.

donmontalvo
Esteemed Contributor III

@rockpapergoat Thanks...tested fine, the asset team sends their thanks!

--
https://donmontalvo.com