How can I find which version of OSX is installed on my Mac by using AppleScript? I want to install an app programatically and run different pkg files based on the version.
You can get the OS version as a display string using:
set _versionString to system version of (system info)
If you want to compare this to another version, be sure to use considering numeric strings:
considering numeric strings
set _newEnough to _versionString ≥ "10.9"
end considering
Otherwise, you can run into problems such as "10.4.11" being less than "10.4.9", or "10.10" being less than "10.9".
You can also use system attribute. This lets you get the version number as an integer so that you don't need to worry about comparing dot-separated strings:
set _versionInteger to system attribute "sysv" -- 4240 == 0x1090 (Mac OS X 10.9)
set _isMavericksOrBetter to (system attribute "sysv") ≥ 4240 -- 0x1090
set _isMountainLionOrBetter to (system attribute "sysv") ≥ 4224 -- 0x1080
set _isLionOrBetter to (system attribute "sysv") ≥ 4208 -- 0x1070
You can also use system attribute to get the individual version components without having to parse a string:
set _major to system attribute "sys1" -- 10
set _minor to system attribute "sys2" -- 9
set _bugFix to system attribute "sys3" -- 0