我有一个运行AppleScript的Shell脚本。该applescript是从终端执行的,我希望该终端在完成后关闭。
在我的shell脚本中,我用这一行执行applescript。它会打开一个终端,运行,然后即使该AppleScript完成,该终端也只是坐在那里。我打开了所有我一直使用的终端,所以我不想只关闭一个终端。
osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript"'
谢谢
最佳答案
在您的Shell脚本中,您执行
osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript"'
什么才真正打开一个新的Terminal.app窗口。
您是否出于某些特殊原因需要打开新的终端窗口?为什么不运行
osascript ~/Scripts/reset_simulator.applescript
从您的Shell脚本中并在当前窗口中。
但是,如果您想要这样的东西(听起来很奇怪),总是可以使用下一个:
osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript;exit"'
#note the "exit" here ---------------------------------------------------------------------------------^^^^^
退出后,将“首选项”更改为“关闭窗口”。
在上面阅读您的评论,听起来比您想在“背景”中运行一些applescript听起来要好得多。
因此,您可以执行以下操作:
a。)从您的shell脚本
osascript ~/Scripts/reset_simulator.applescript &
2.)如果您仍要打开另一个终端窗口
osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript&exit"'
#note the & here --------------------------------------------------------------------------------------^
关于macos - 执行后退出终端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25773238/