checking what version of OS X is installed

How can I check what version of Mac OS X is installed on the computor?

Thanks for the help.

This will do it:

set VersionData to word 2 of paragraph 2 of (do shell script “sw_vers”)

The result looks like this: “10.3.8” and you can extract what you want from that text.

Thanks… that worked perfectly. :slight_smile:

Better to use…

do shell script "sw_vers -productVersion"

j

I like to use gestalt because it can give me other system environment variables. Below are the handlers and examples that I have been using for years. I can’t remember where I found them. “sysv” will give you the system version. The handlers convert it to both an integer (useful for less then conditional statements) and a string separated by periods like in the “Get Info” box.


on gestaltVersion_info(gestalt_code, string_length)
	try
		tell application "Finder" to ¬
			copy my NumToHex((system attribute gestalt_code), ¬
				string_length) to {a, b, c, d}
		set the numeric_version to {a, b, c, d} as string
		if a is "0" then set a to ""
		set the version_string to (a & b & "." & c & "." & d) as string
		return {numeric_version, version_string}
	on error
		return {"", "unknown"}
	end try
end gestaltVersion_info

on NumToHex(hexData, stringLength)
	set hexString to {}
	repeat with i from stringLength to 1 by -1
		set hexString to ((hexData mod 16) as string) & hexString
		set hexData to hexData div 16
	end repeat
	return (hexString as string)
end NumToHex

-- Check the version of the OS
copy my gestaltVersion_info("sysv", 4) to {system_version, system_string}
if the system_version is less than "0850" then
	display dialog "This script requires Mac OS 8.5 or higher." & ¬
		return & return & "The currently installed version is: " & ¬
		system_string buttons {"Cancel"} default button 1
end if

-- Check the version of AppleScript
copy my gestaltVersion_info("ascv", 4) to {AppleScript_version, AppleScript_string}
if the AppleScript_version is less than "0137" then
	display dialog "This script requires AppleScript 1.3.7 or higher." & ¬
		return & return & "The currently installed version is: " & ¬
		AppleScript_string buttons {"Cancel"} default button 1
end if

-- Check the version of QuickTime
copy my gestaltVersion_info("qtim", 8) to {QT_version, QT_string}
if the QT_version is less than "0400" then
	display dialog "This script requires QuickTime 4.0 or higher." & ¬
		return & return & "The currently installed version is: " & ¬
		QT_string buttons {"Cancel"} default button 1
end if

-- Check the version of ColorSync
copy my gestaltVersion_info("cmtc", 4) to {ColorSync_version, ColorSync_string}
if the ColorSync_version is less than "0261" then
	display dialog "This script requires ColorSync 2.6.1 or higher." & ¬
		return & return & "The currently installed version is: " & ¬
		ColorSync_string buttons {"Cancel"} default button 1
end if

drossi said:

Actually, applescript is smart enough to determine whether a string is greater than or less than another string. You shouldn’t need to explicitly coerce it into an integer to figure out if one is greater than the other…

set var1 to "10.3.2"
set var2 to "10.3.1"

var1 > var2 --> returns true
var1 < var2 --> returns false

j

Hi,

Does anyone know to obtain the Gestalt Table or a Gestalt Mapping Sys for AS?

Example:
i. system attribute “sysv” -->rtns: Current Sys Ver in Hex
ii. system attribute “ascv” -->rtns: Current AS Ver in Hex