Login  •  Register


The time is now: Sun Sep 24, 2017 5:02 am

Emaculation wiki  •  Delete all board cookies



Post new topic  Reply to topic Page 1 of 1 [ 17 posts ]
Print view Previous topic  |  Next topic
Author Message
PostPosted: Sun Aug 06, 2017 2:49 pm 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 725
I've been working on an AppleScript application that launches SheepShaver. If SheepShaver starts up and displays the question-mark icon, I'd like to be able to detect this and kill SheepShaver, notifying the user what has happened.

Is there any way to accomplish this? I don't see anything in the Console that might report when SheepShaver didn't open a disk file.

Thanks for any suggestions.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Aug 06, 2017 3:13 pm 
Offline
Forum All-Star
User avatar

Joined: Fri Nov 27, 2009 5:11 am
Posts: 1756
lsof will tell you which files and handles are opened. You could check and see if the open handles differ between the ? state and a loading state....


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Aug 06, 2017 3:18 pm 
Offline
Expert User
User avatar

Joined: Fri Feb 13, 2004 8:59 am
Posts: 4170
Location: Sittard, The Netherlands
When does the blinking question mark happen?
-When no boot file is found
-When a boot file is found, but it is defective (i.e. not blessed correctly)

Simple solution might be to check whether the designated boot file hasn't been accessed for, say, the last 4 seconds in a 5 second period from start?

Best,
cat_7


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Aug 06, 2017 3:31 pm 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 725
Cat_7 wrote:
When does the blinking question mark happen?
-When no boot file is found
-When a boot file is found, but it is defective (i.e. not blessed correctly)

Simple solution might be to check whether the designated boot file hasn't been accessed for, say, the last 4 seconds in a 5 second period from start?


I should have explained further. I've been modifying my "Mac OS 9" application (an AppleScript that contains a copy of SheepShaver and a disk image) so that multiple users can run it from the Applications folder.

This works smoothly if one user starts the application, runs it, and then shuts it down before another user starts up the same application. However, if one user starts the application, and then a second user also tries to run the application, SheepShaver displays the question mark icon to the second user.

I've tried to find ways to detect whether SheepShaver is already running in a process owned by the first user, so that I could warn the second user and not start SheepShaver at all, but nothing I've tried has worked. (I probably haven't looked hard enough.) So I thought the simplest way might be to detect the question mark icon. Either way would get the job done: either detect the other user's process before launching SheepShaver or detect the question mark icon and shut down the new instance of SheepShaver.

I've already tried testing whether the disk image is writable when another user is accessing it via SheepShaver, but OS X/macOS always reports that the image is writable. I've tried various forms of the "ps" shell command, but i haven't found anything that solves the problem.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Aug 06, 2017 3:36 pm 
Offline
Expert User
User avatar

Joined: Fri Feb 13, 2004 8:59 am
Posts: 4170
Location: Sittard, The Netherlands
Then adespoton's tip might work: see whether the file is already open.

Best,
Cat_7


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Aug 06, 2017 3:53 pm 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 725
Thanks for that, but lsof is one the many things I've already tried. It doesn't report files opened by another user unless you use sudo, and that isn't practical for ordinary use.

I'll be grateful for any other ideas!


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Aug 06, 2017 6:44 pm 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 725
OK, I solved this by writing this script to detect whether the current user or another user is running SheepShaver. It's a terrible kludge, but it seems to work. (What's missing is a test whether the other user's SheepShaver is the same copy as the local user's.)

Code:
set myName to do shell script "whoami"
set allNames to do shell script "users"
set listNames to my stringSplit(allNames, " ")
set deleteMe to {myName}
set otherNames to {}

repeat with i from 1 to count listNames
   if {listNames's item i} is not in deleteMe then set otherNames's end to listNames's item i
end repeat

set activeOther to false
repeat with i from 1 to count otherNames
   set appFound to do shell script "ps -U" & space & otherNames's item i & space & "| grep SheepShaver | grep psn | awk '{print $1}'"
   if appFound is not "" then set activeOther to true
end repeat

set activeHere to false
if application "SheepShaver" is running then set activeHere to true

set otherString to "being run by another user"
if activeOther is false then set otherString to "NOT" & space & otherString

set localString to "being run by you," & space & myName
if activeHere is false then set localString to "NOT" & space & localString

tell me to activate
display dialog "SheepShaver:" & return & return & "is" & space & otherString & return & return & "is" & space & localString buttons {"OK"}

on stringSplit(theString, theDelimiter)
   set oldDelimiters to AppleScript's text item delimiters
   set AppleScript's text item delimiters to theDelimiter
   set theArray to every text item of theString
   set AppleScript's text item delimiters to oldDelimiters
   return theArray
end stringSplit


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Aug 06, 2017 7:56 pm 
Offline
Expert User
User avatar

Joined: Thu Feb 09, 2006 10:24 pm
Posts: 4800
Location: Amsterdam, Netherlands
Just wondering:
You want different users use the same startup volume, though not at the same time. Using the volume will make changes to that volume. Imagine: User 1 uses SheepShaver and quits. Then user 2 uses SheepShaver and quits. Then again user 1 uses SheepShaver. Wouldn't user 1 be confused by changes made by user 2?


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Aug 06, 2017 8:26 pm 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 725
Ronald P. Regensburg wrote:
Just wondering:
You want different users use the same startup volume, though not at the same time. Using the volume will make changes to that volume. Imagine: User 1 uses SheepShaver and quits. Then user 2 uses SheepShaver and quits. Then again user 1 uses SheepShaver. Wouldn't user 1 be confused by changes made by user 2?


Yes, that could be confusing. Of course each user could install the a separate copy of the app in his or her home folder somewhere, and then they would never get in each other's way. I'll leave it as it stands for now, because I made the change only in response to the thread about Chubby Bunny and permissions, and this at least gets things started.

One possibility is to share a startup volume and have each user have his or her own data volume, which only gets mounted when that user launches the application. But that's a job for another time.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Mon Aug 07, 2017 7:17 am 
Offline
Expert User
User avatar

Joined: Thu Feb 09, 2006 10:24 pm
Posts: 4800
Location: Amsterdam, Netherlands
emendelson wrote:
One possibility is to share a startup volume and have each user have his or her own data volume, which only gets mounted when that user launches the application. But that's a job for another time.

Unless the startup volume is locked, changes will be made to the System Folder, certainly to preferences settings and control panel settings. Software installations could add new extensions or control panels. Experienced users may disable/enable extensions and control panels, or add/remove startup items.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Mon Aug 07, 2017 3:02 pm 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 725
Probably what I should do in a multiuser system is (1) lock the system disk and (2) create a new data disk for each user who starts the system, and store it in the user's Application Support folder (testing for its existence at startup). This wouldn't be hard, presumably.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Mon Aug 07, 2017 5:53 pm 
Offline
Expert User
User avatar

Joined: Thu Feb 09, 2006 10:24 pm
Posts: 4800
Location: Amsterdam, Netherlands
That setup will prevent proper installation of software that installs files in the System Folder. It may work otherwise.

Wouldn't it be much simpler when each user has his/her own copy of the whole package? Why does it need to be shared?


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Mon Aug 07, 2017 5:59 pm 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 725
Ronald P. Regensburg wrote:
That setup will prevent proper installation of software that installs files in the System Folder. It may work otherwise.

Wouldn't it be much simpler when each user has his/her own copy of the whole package? Why does it need to be shared?


It doesn't have to be shared. I was trying to work out a way to accomplish what someone was trying to solve with Chubby Bunny in another thread. This is mostly an intellectual exercise - a way of learning AppleScript. I'll go back to the single-user model.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Aug 08, 2017 11:22 am 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 725
Ronald P. Regensburg wrote:
Unless the startup volume is locked, changes will be made to the System Folder, certainly to preferences settings and control panel settings. Software installations could add new extensions or control panels. Experienced users may disable/enable extensions and control panels, or add/remove startup items.


Wait - I forgot that OS 9 under SheepShaver supports the Multiple User feature. This means that a SheepShaver-based app can be in the application folder, with only one disk image, and each user can log in separately to OS 9, just as they did with real multi-user systems in the OS 8/9 era.

As you say, it's simpler for each user to have his or her own copy of the application, but a multi-user system is certainly feasible.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Aug 15, 2017 2:40 pm 
Offline
Mac Mechanic
User avatar

Joined: Tue Mar 29, 2011 8:57 pm
Posts: 183
Location: London, UK
Medusa can kill SS. It doesn't detect it, of course. It is open-source, so feel free to fork it.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Aug 15, 2017 5:40 pm 
Offline
Forum All-Star
User avatar

Joined: Fri Nov 27, 2009 5:11 am
Posts: 1756
One other option here, although it might make things too complex for the use case:

Modern disk images have the ability to enable shadow copies. So you could have a separate shadow copy for each user, adding the username into the shadow copy filename. That way, you have one base image, but the changes each user makes go into their own shadow copy. That way, you have something distributable, but each user gets their own data set.

Would that help?


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Aug 15, 2017 5:52 pm 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 725
Updates on this system are now in a more appropriate thread:

viewtopic.php?f=33&t=9358

Briefly: I rewrote the application so that it works for multiple users without any effort. Each user can (optionally) create a non-booting disk image that will only be visible when that user is running the application (it's stored in the user's ~/Library/Application Support folder). If an administrator wants to set it the system as a multi-user OS 9 system, that admin is free to do so. Otherwise, it works exactly the way a real OS 9 Mac would work if it were accessible to more than one user.

However, I hope you will spell out exactly how your suggestion could be put into effect - with full details of the exact commands involved, how to set up permissions, etc. This could be very useful for anyone else who works with SheepShaver. Without the full details that you can provide, probably no one will have any real idea of how to put your idea to use, and people might waste many hours trying various things that won't work. You could prevent this by providing real, practical, tested details. Thank you in advance for any information!


Top
 Profile  
Reply with quote Post a reply  
Display posts from previous:  Sort by  
Post new topic  Reply to topic Page 1 of 1 [ 17 posts ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
 

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group