【发布时间】:2016-04-09 15:40:02
【问题描述】:
AppleScript 新手,但我正在尝试从终端脚本迁移过来。经过大量研究后,我在尝试从 .app 文件中运行 shell 脚本时遇到问题。
到目前为止我所拥有的:
to the_foo()
tell application "Finder"
set current_path to container of (path to me) as alias
set path_in_posix to POSIX path of current_path
end tell
tell application "Terminal"
set new_terminal to do script " "
activate
do script "cd " & path_in_posix in window 1
do shell script "ls " & POSIX path of (path to me) & "Contents/Resources/Scripts/foobar.sh" in window 1
end tell
end the_foo
我得到的错误:
学会用Applescript to open a NEW terminal window in current space打开一个新终端
我在得知do script每次都会打开一个新的终端窗口时添加了in window 1,引用:applescript and terminal ( run several do shell script in one terminal window )
我最初尝试过:
set script_Location to path to resource "Contents:Resources:Scripts:"
set run_Script to (quoted form of script_Location) & "foobar.sh"
do shell script run_Script
引用后:How to change AppleScript path to a Terminal-style path? 但是当我运行它时,我得到了同样的错误。
那么如何运行位于同一window 1 中Scripts 文件夹中的shell 脚本?理想情况下,我想为路径设置一个变量,这样我就可以将多个 shell 脚本放在 Scripts 文件夹中。
【问题讨论】:
标签: bash shell terminal applescript