Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash脚本调用AppleScript错误_Bash_Shell_Applescript_Macos Mojave - Fatal编程技术网

Bash脚本调用AppleScript错误

Bash脚本调用AppleScript错误,bash,shell,applescript,macos-mojave,Bash,Shell,Applescript,Macos Mojave,我有两个脚本,第一个是bash,第二个是macOS 10.14 mojave上的AppleScript。我正在从Bash调用AppleScript,结果出错。如果我直接运行AppleScript,它将毫无问题地运行 若我运行bash脚本来执行AppleScript,我将得到对话框“错误:找不到应用程序标识符” 若我在脚本编辑器中运行AppleScript,它将在对话框中显示正确的(org.mozilla.firefox)应用程序标识符 为什么在运行bash脚本执行AppleScript时不显示应

我有两个脚本,第一个是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
AppleScript:

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

我无法将两个脚本放在一个脚本中,需要将它们分别放在脚本中。

打开Firefox时可能会出现时间问题,而脚本中可能没有考虑到这些问题。尝试将
告诉应用程序“Firefox”激活
延迟1
添加到applescriptw中,你认为如何?这对我来说是可行的,在macOS High Sierra下没有问题,因此这可能是macOS Mojave特有的问题。