例如在教程here中
tell application "Finder"
Finder是我系统中的一个应用程序。
Terminal
也是如此。
但是,如果我将Terminal
替换为iTerm
,这也是我的应用程序列表中名为的应用程序,那么它将无效。即使它显示在SO的一些答案中,如下面的
#!/bin/bash
osascript -e '
tell app "iTerm"
activate
tell the first terminal
launch session "Default Session"
tell the last session
set name to "New Session"
write text "cd /usr/bin; ls"
end tell
end tell
end tell'
它将返回错误
52:60: syntax error: Expected class name but found identifier. (-2741)
或类似
#!/bin/bash
osascript -e '
tell application "Terminal"
do script "date"
activate
end tell'
可行,但当我将Terminal
替换为iTerm
时,会返回35:41: syntax error: Expected end of line but found “script”. (-2741)
的错误
所以怀疑我使用了错误的应用名称,即使看起来iTerm
是实际的应用名称,但似乎没有,因为它导致上面的错误。如果我可以列出我可以使用的实际应用程序名称,它可以帮助我解决它
*注意:我安装了iTerm,这就是我想引用它的原因......