如何在 do 脚本中使用 apple 脚本的命令行参数?

How to use a command line argument of apple script in do script?

在terminal.app我正在执行命令。

 osascript filename.scpt 'argument1' 'argument2'

filename.scpt 脚本将在 运行 时根据收到的第二个参数设置名为 scriptName 的变量来自 CL.

  set scriptName to item 2 of argv

然后 filename.scpt 将在 do scrip[=28= 中使用变量 scriptName ]t 命令用于 do 脚本的参数“UIASCRIPT

        do script "instruments -w <have given my device id>  -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate com.merucabs.merucabs -e UIASCRIPT  -e " & scriptName & " UIARESULTSPATH ~/Desktop/traceoutput;" in newWin

但是当我 运行 代码时,我收到一条错误消息:

2015-06-05 12:28:07.258 instruments[3667:109611] Argument 'UIASCRIPT' does not point to a valid script. Using script defined in template.

我弄明白了谢谢大家!!

问题在于将 -e 放在脚本名称之前而不是之后...

    do script "instruments -w " & device_id & " -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate " & bundle_name & " -e UIASCRIPT " & script_path & " -e UIARESULTSPATH " & trace_output & ";" in newWin