【问题标题】:How to pass value from apple script to shell script in Automator?如何将值从苹果脚本传递到 Automator 中的 shell 脚本?
【发布时间】:2021-06-06 02:38:25
【问题描述】:

我打算运行一个 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}

结束运行

【问题讨论】:

    标签: macos shell applescript automator


    【解决方案1】:

    首先请发布文字,而不是图片。

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

    你必须写

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

    【讨论】:

      猜你喜欢
      • 2010-12-23
      • 1970-01-01
      • 2021-09-20
      • 1970-01-01
      • 1970-01-01
      • 2016-10-29
      • 2022-09-27
      • 2022-06-11
      • 2016-12-01
      相关资源
      最近更新 更多