问题描述
我计划先运行一个 shell 脚本,然后运行一个 AppleScript。但是我想知道是否可以将参数值传递给shell脚本,如下所示。
我遇到了一些我不明白的奇怪错误。有人可以帮助我理解错误并提供一种将值(继续/不继续)从 Apple Script 传递给 Shell 脚本的方法吗?
文本格式的代码:
on run {input,parameters}
set theDialogText to "By running this script,it will update your hosts file. Would you like to continue?"
set isupdate to display dialog theDialogText buttons {"Don't Continue","Continue"} default button "Continue" cancel button "Don't Continue"
return {isupdate}
结束运行
解决方法
首先请发布文字,而不是图片。
发生错误是因为 display dialog
返回一个记录(就 Objective-C 而言是一个字典)但参数必须是一个字符串。
你必须写
set isUpdate to button returned of (display dialog ... )