Run and Close Application from Terminal in Mac OS X

Run

To run any application from terminal of mac os x write the following in terminal:

open -a safari

Close

To close the application from terminal(without kill process) use the following command:

osascript -e ‘tell application “safari” to quit’

(here safari is just an example)

Advertisements

6 thoughts on “Run and Close Application from Terminal in Mac OS X

  1. nlapjr.

    great! big help. thank you very much!
    i found an applescript to do the same thing but a single line from the terminal like this
    one is better.

  2. Works a champ in Yosemite Public Beta 2. I want to fire up Thunderbird to download my Gmail every day. So I open, sleep 900 (15 minutes) and then use that little bit of AppleScript to close it. I prefer the web app to Thunderbird but that way I make copies of all my mail.

    Thanks!

  3. Open works, but close does not.

    osascript: ‘tell: No such file or directory — No longer seems to work. I am in Yosemite

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s