Quit applications from the command line

Jun 25, '04 09:15:00AM

Contributed by: TrumpetPower!

The recent hint to "Extend the power of 'open -a'� inspired me to write this quick hack to quit an application:

#!/bin/sh

echo | osascript <<EOF
tell application "$*"
  quit
end tell
EOF
Call it quit, save it in your $PATH (I'm a fan of $HOME/bin), make it executable (chmod 755 quit), and then, for example, quit mail will do just that.

I don't tend to put lots of error handling in programs for my own use. You could easily add all sorts of things, like checking return codes and reporting success ... but, if you're the only one to ever run it, why bother Enjoy!

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040623231530448