Josh Lesch
Josh Lesch

Reputation: 405

exit terminal after execution

I have a shell script that runs an applescript. The applescript is executed from a terminal and I want that terminal to close after its done.

In my shell script I execute my applescript with this line. It opens a terminal, runs and then the terminal just sits there even though the applescript is done. I have other terminals open that I use all the time so I don't want to close all of them, just that one.

 osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript"'

Thanks

Upvotes: 3

Views: 8751

Answers (2)

clt60
clt60

Reputation: 63972

In your shell script, you executing the

osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript"'

what really opens an new Terminal.app window.

Have you some special reason to open an new terminal window? Why just not running the

osascript ~/Scripts/reset_simulator.applescript

from your shell script and in the current window.

But if you want such thing (sounds to me strange) always can use the next:

osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript;exit"'
#note the "exit" here ---------------------------------------------------------------------------------^^^^^

and change the Preferences to "close window" when the shell exits.

Reading your comments above, sounds me than you want run some applescript in the "background".

So you can do the next:

a.) from your shell script

osascript ~/Scripts/reset_simulator.applescript &

2.) if you want still open the another terminal window

osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript&exit"'
#note the & here --------------------------------------------------------------------------------------^

Upvotes: 4

nneonneo
nneonneo

Reputation: 179687

In your Terminal settings, change the setting under "Shell->When the shell exits" to "Close if the shell exited cleanly".

Settings

Upvotes: 1

Related Questions