首页 > 解决方案 > How to pass value from apple script to shell script in Automator?

问题描述

I'm planning to run a shell script followed by a AppleScript. But I would like to know if it is possible to pass a parameter value to shell script as follows.

enter image description here

I'm getting some weird error which I do not understand. Can someone please help me understand the error and provide a way to pass value (Continue/Don't Continue) to Shell script from Apple Script?

Code in Text format:

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}

end run

标签: macosshellapplescriptautomator

解决方案


首先,请发布文本,而不是图像。

发生错误是因为display dialog返回一条记录(根据 Objective-C 字典),但参数必须是字符串。

你必须写

set isUpdate to button returned of (display dialog ... )

推荐阅读