How to tell if OS9 is running under X or not?

I’d like to make a script that can tell wether OS 9 is running under OS X (as classic) or not.
I guess it should look something like this, but I don’t know of a way to tell wether OS 9 is running as classic.


if runningAsClassic() is true then
	-- do something
else
	-- do something else
end if

runningAsClassic()
-- code telling wether or not OS9 is running as classic
return true
end

Maybe one could check for an OS X application?

/arvid

Here’s one way to tell if Classic is running or not…

do shell script "ps cax | grep -i TruBlue | awk '{print $5}'"
if result = "truBlueEnvironme" then
	display dialog "Classic is running"
else
	display dialog "Classic is not running"
end if

Here’s another way…

tell application "Finder"
	activate
	if name of every process contains "Classic Support" then
		display dialog "Classic is running"
	else
		display dialog "Classic is not running"
	end if
end tell

Thanks for the reply, but it didn’t solve my problem. I want a script running in classic/OS 9 to be able to tell if Mac OS 9 is running as Classic or if it is running without OS X.

The reason for me wanting this is that I want to launch DragThing for OS 9 if OS 9 is running as the only OS, but if it is running as classic I don’t want DragThing for OS 9 to start as I already have DragThing for X started.

/arvid

Oh, I was wrong there. I used the second script, and it worked fine for me.
The resulting script:


tell application "Finder"
	activate
	if name of every process contains "Classic Support" then
		--do nothing
	else
		open file "DragThing 2.9" of folder "DragThing 2.9 ?" of folder "Applications (Mac OS 9)" of disk "Macintosh HD"
	end if
end tell

Thank you very much for the help Greg! :slight_smile:

/arvid