Hi
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.
Thanks
Hi
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.
Thanks
I'm not too familiar with AppleScript, but AFAIK you can get some info about versions from the shell with the sw_vers command.
e.g.,:
ProductName: Mac OS X ProductVersion: 10.5.6 BuildVersion: 9G55 Macintosh:~ udekel$
If you can read and parse that from appleScript, that may be a solution, though I'm sure there has to be something more elegant.
I'm not on a Mac, so there may be a better way to do this, but the first approach that comes to mind is just executing a shell command to query the OS version.
http://developer.apple.com/technotes/tn2002/tn2065.html#TNTAG2
http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man1/sw_vers.1.html
Based on these references, you probably want to do something like:
set os_version to do shell script "sw_vers -productVersion"
Try something along these lines:
tell application "Terminal"
activate
set theVersion to do script with command "sw_vers -productVersion"
end tell
Edit : It was pointed out that this does open the terminal, and that probably isn't the behavior you want.
You can get version from the Finder app as well
tell application "Finder"
set os_version to version
end tell
display dialog os_version
On my machine this displays "10.5.8".