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

mishka00

macrumors newbie
Original poster
Nov 17, 2008
12
0
Hello!

I've got a script that I run to unmount all devices as follows:

Code:
#!/bin/sh
osascript -e 'tell application "Finder" to eject (disks where free space * 0)'

When I double-click it, it launches in a terminal window and displays the following:

Code:
MacbookPro:~ Mishka00$ /Users/Mishka00/Scripts/unmount_all ; exit;
logout

[Process completed]

The devices get unmounted ok, that's fine, but the terminal window remains open. I'd like it to automatically close (and the terminal to exit as well, for that matter).

Please help. Thanks.
 
Think that's a Terminal preference thing. I guess you could do a ps and search for Terminal's PID and kill it, however, if a user has more than one Terminal, you'd have to search for the parent PID in your script, then kill it later on. If this is just for you, then it's not that important: just change Terminal's pref's to auto-close.
 
What about ending the script with "killall Terminal"?

I tried that but got a message
"No matching processes belonging to you were found"
which is probably related to the user permissions or some such. As I'm just a recent convert from Windoze, I didn't research this much, but I did find an alternative way to kill the terminal from the script which works flawlessly:

osascript -e 'tell application "Terminal" to quit'

Thanks for the help, anyway.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.