我有 2 个脚本,第一个是 bash,第二个是我的 macOS 10.14 mojave 上的 AppleScript。我从 Bash 调用 AppleScript 并收到错误。如果我直接运行 AppleScript,它将毫无问题地运行。
如果我运行 bash 脚本来执行 AppleScript,我会得到对话框“错误:找不到应用程序标识符”。
如果我在脚本编辑器中运行 AppleScript,它将显示正确的(org.mozilla.firefox)应用程序标识符和对话框。
为什么当我运行 bash 脚本来执行 AppleScript 时它不显示应用程序标识符。
bash 脚本:
#!/bin/bash
/usr/bin/osascript /Users/mymac/Desktop/tst.scpt
苹果脚本:
property IDI : "NOTSET"
try
set IDI to bundle identifier of (info for (path to application "Firefox"))
display dialog " Identifier is " with title "Test" buttons {"Exit"} default answer IDI
end try
if IDI is "NOTSET" then
display dialog "ERROR: Unable to find application identifier." with title "Test" buttons {"Exit"}
return
end if
我不能将两个脚本都放在一个脚本中,需要将它们分别放在脚本中。