Shut down SheepShaver from OS X

About SheepShaver, a PPC Mac emulator for Windows, MacOS X, and Linux that can run System 7.5.3 to MacOS 9.0.4.

Moderators: Cat_7, Ronald P. Regensburg, ClockWise

Post Reply
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Shut down SheepShaver from OS X

Post by emendelson »

An earlier post in the forum asked if it were possible to shut down SheepShaver from OS X - without going through the routine of shutting down the Mac OS in SheepShaver.

That seemed like an interesting problem, and here's a solution, based entirely on an idea that John Rethorst invented (in the WordPerfectMac Yahoo group) for using WPMac in SheepShaver to open WP files on the OS X desktop.

First, inside SheepShaver, paste the following script into the Mac OS 8/9 Script Editor. Then, using the Save dialog box, save it as Kind: Application, with the "Stay Open" and "Never Show Startup Screen" options both checked. Name it whatever you like, perhaps "ShutMeDown". Move the script into the Startup Items folder in the System Folder in SheepShaver.

Here is the script:

Code: Select all

global shutSignal, shutFound

on run
	tell application "Finder"
		set shutSignal to ("Unix:shutSignal.txt")
		try
			set shutFound to true
			tell application "Finder"
				set shutSignal to shutSignal as alias
			end tell
		on error
			set shutFound to false
		end try
	end tell
	
	if shutFound is true then
		tell application "Finder" to delete shutSignal
		delay 1
	end if
end run

on idle
	tell application "Finder"
		try
			set shutSignal to shutSignal as alias
			my doShutdown()
		on error
			return 0.5
		end try
	end tell
end idle

on doShutdown()
	tell application "Finder" to delete shutSignal
	tell application "Finder" to shut down
	error number -128
end doShutdown
Someone who actually knows something about AppleScript could probably make this much more efficient.

Now, with SheepShaver still open, open the SheepShaver Preferences, find the field labeled "Unix Root:" and take careful note of the path in that field. (I can't copy the path it to the clipboard from the SheepShaver build that I use; you may be luckier.) Cancel your way out of the preferences, and shut down SheepShaver.

Next, in the OS X Script Editor (or AppleScript Editor, depending on your OS X version), create a new, blank script, and type the following in the first line:

Code: Select all

set signalPath to "
Notice the space followed by a quotation mark. Immediately after the quotation mark, type the path that you found in the SheepShaver preferences, so that the line looks something like this:

Code: Select all

set signalPath to "/Users/yourname/Documents/  
but of course with the actual path that you found in the SheepShaver preferences, NOT the path I typed here, which is guaranteed not to work on your system.

Next, type in the filename shutSignal.txt followed by a quotation mark, so the line looks like this:

Code: Select all

set signalPath to "/Users/yourname/Documents/shutSignal.txt" 
Finally, add a second line to the script, so that the whole script looks something like this:

Code: Select all

set signalPath to "/Users/yourname/Documents/shutSignal.txt"
do shell script "echo >" & quoted form of signalPath
Again, the path in the first line absolutely must be the actual path of the Unix Root folder on your system, NOT what I typed into the example.

Save this script to your OS X desktop as an application; perhaps name it SheepShut.

Now, start up SheepShaver. The ShutMeDown script will automatically run in the background while you run any other program you want to run in SheepShaver.

If you want to quit SheepShaver from OS X, perhaps because the SheepShaver window is minimized, or you're working on something else in OS X, run the SheepShut script in OS X. Be patient. After a few seconds, SheepShaver will shut down.

Probably this can be made faster by changing the delay in the SheepShaver script. Any suggestions will be useful
Post Reply