如何将值从苹果脚本传递到 Automator 中的 shell 脚本?

问题描述

我计划先运行一个 shell 脚本,然后运行一个 AppleScript。但是我想知道是否可以将参数值传递给shell脚本,如下所示。

enter image description here

我遇到了一些我不明白的奇怪错误。有人可以帮助我理解错误并提供一种将值(继续/不继续)从 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 ... )

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...