Determining OS -- Tiger vs. Leopard

I understand that the easiest way to determine whether a Mac is running Tiger vs. Leopard is to use the system attribute “sysv”.

On a Mac running Tiger 10.4.11, I see that system attribute returns 4169.

What will the sysv value be if I was running Leopard 10.5? 10.5.1?

(I want to make sure my script does NOT run on a Leopard computer. But I do not have a Mac running leopard tp find out the sysv values).


Hi Rob,

two options:

set isLeo to (version as text) starts with "2" --> checkes the AppleScript version, 1 ist Panther or Tiger, 2 is Leopard


set isLeo to ((system attribute "sysv") mod 4096 div 16) = 5 --> masks the middle number (x) of 10.x.y

Thanks Stefan for the quick reply. Know I understand how to determine the OS version from the number that system attribute “sysv” returns.

I also did some more digging and found this alternate solution using the “system info” command…

if (system version of (system info)) ≥ "10.5" then
	display dialog "Running Leopard"
	display dialog "Running Tiger or previous OS X version"
end if

I am not sure which is the ebst approach. It looks like he two approaches in your post and this approach above will all work equally well.


You’re right.
Just for your information:
system attribute returns

4169 for 10.4.9
1 * 16 ^ 3 = 4096 (10 is taken as 1)
4 * 16 ^ 2 = 64
9 * 16 ^ 1 = 9
----------------- 4169

and 4177 for 10.5.1
1 * 16 ^ 3 = 4096
5 * 16 ^ 2 = 80
1 * 16 ^ 1 = 1
----------------- 4177


1 * (16 ^ 3) = 4096
0 * (16 ^ 2) = 0
4 * (16 ^ 1) = 64
9 * (16 ^ 0) = 9


The annoying thing about methods for finding the system version is that most of them only work with certain system versions! system info, for instance, was introduced sometime between Jaguar and Tiger and is no good on systems earlier than its introduction. Before Mac OS X, system attribute, now in the StandardAdditions, used to be a Finder command called computer. Fortunately, they used the same underlying token, so if you wrote:

tell application "Finder" to set sysv to computer "sysv"

. the script compiled and worked on any system, although computer appeared as system attribute when viewed in OS X. This still works in Tiger.

If you simply want to differentiate between pre- and post-Leopard systems, you can pre-calculate that the “sysv” value for 10.5.0 is 4176 and use that in the script:

if ((system attribute "sysv") < 4176) then
	-- Pre-Leopard
	-- Leopard or later.
end if

I believe is was Tiger. You also couldn’t compare AppleScript version strings because considering numeric strings (also introduced in Tiger) was needed to properly compare “1.10” to “1.9”.

:lol: Oh my goodness, yes, of course

But both my solutions in the first post work in all system versions :wink:

Yes, indeed :slight_smile: ” even under AppleScript 1.8.3 in OS 9.2.2, as it turns out ” provided of course that the version solution isn’t used in that form in a tell block to something else that also has a version property. AppleScript’s version should be specified in that case.

The Standard Additions OSAX in AppleScript 1.8.3 also has the system attribute command. I can’t remember for sure now, but I believe it was implemented some time around OS 9.2 to increase compatibility with the emerging OS X. The OS 9.2.2 Finder still has the computer command in its Finder Basics suite.

The AppleScript version can also be got with a system attribute call. It’s not quite as fast as getting the version property directly from AppleScript, but processing the result is faster, so it works out about the same:

if ((system attribute "ascv") mod 65536 < 512) then
	-- Pre-AppleScript 2.0.
	-- AppleScript 2.0 or later.
end if