简体   繁体   English

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

[英]How to pass value from apple script to shell script in Automator?

I'm planning to run a shell script followed by a AppleScript.我计划运行 shell 脚本,然后运行 AppleScript。 But I would like to know if it is possible to pass a parameter value to shell script as follows.但我想知道是否可以将参数值传递给 shell 脚本,如下所示。

在此处输入图像描述

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?有人可以帮我理解错误并提供一种将值(继续/不继续)从 Apple Script 传递给 Shell 脚本的方法吗?

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结束运行

First of all please post text, not an image.首先,请发布文本,而不是图像。

The error occurs because display dialog returns a record (in terms of Objective-C a dictionary) but the parameter must be a string.发生错误是因为display dialog返回一条记录(就 Objective-C 而言是字典),但参数必须是字符串。

You have to write你必须写

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM