Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Zeke D

macrumors 65816
Original poster
Nov 18, 2011
1,024
168
Arizona
I am using the following script:

Code:
tell application "Terminal"
	activate
	do script "cd /Volumes/iTunes/" in front window
	do script "./ToastImageMounter ZooTycoon2NoCD.toast" in front window
	do script "open 'Zoo Tycoon 2.app'" in front window
	do script "exit" in front window
	close front window without saving
end tell

It prompts me to click on the close button in the terminal window, and still leaves terminal active in the dock. what modifications would you suggest? If I could I wouldn't even have a terminal window at all.
 

Attachments

  • Picture 2.png
    Picture 2.png
    38 KB · Views: 243
Last edited:
You can use do shell script from Standard Additions - see Technical Note TN2065. Note that each do shell script statement runs in a separate generic shell, but a semicolon can be used to separate multiple commands in a single statement. Using && to separate commands will stop later commands if there is an error, for example:

Code:
do shell script "cd /Volumes/iTunes/ && ./ToastImageMounter ZooTycoon2NoCD.toast && open 'Zoo Tycoon 2.app'"
 
Thanks that helped.

I used the same methodology to do the following:

Code:
do shell script "hdiutil attach '/Volumes/iTunes/SimCity 4 Rush Hour.dmg' && open '/Volumes/iTunes/SimCity 4 Deluxe/SimCity 4 Rush Hour.app' && hdiutil detach '/Volumes/SimCity 4 Rush Hour'"

of course detach detaches right away, and SC4 barfs. can applescript do loops?
 
Last edited:
What purpose would a loop serve?

This is a request to explain what you're trying to accomplish (the intended purpose of a loop), rather than how you're trying to accomplish it (with a loop).

I think you might be asking how a delay can be inserted, but I'm not sure about that, since neither a delay nor a loop would let you detach the DMG while an app is still running from it. If the intent is to wait until the app has quit before detaching the DMG, then that's a bigger problem to solve than "Can AppleScript do loops?".
 
What purpose would a loop serve?

This is a request to explain what you're trying to accomplish (the intended purpose of a loop), rather than how you're trying to accomplish it (with a loop).

I think you might be asking how a delay can be inserted, but I'm not sure about that, since neither a delay nor a loop would let you detach the DMG while an app is still running from it. If the intent is to wait until the app has quit before detaching the DMG, then that's a bigger problem to solve than "Can AppleScript do loops?".

Indeed. I would want it to detach the dmg after the program has finished running.
 
You will need some way to determine when the application quits - your script can poll the running applications via System Events, or if your script is a Cocoa-AppleScript application it can register as an observer via NSWorkspace, or you can install something like Do Something When, etc.
 
You will need some way to determine when the application quits - your script can poll the running applications via System Events, or if your script is a Cocoa-AppleScript application it can register as an observer via NSWorkspace, or you can install something like Do Something When, etc.

Sounds like polling or system events would add extra CPU/memory cycles. I guess leaving the images mounted is not a big deal, as they cold o ly be used to load he programs again. Thanks for the help guys.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.