macos - 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.
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
解决方案
首先,请发布文本,而不是图像。
发生错误是因为display dialog
返回一条记录(根据 Objective-C 字典),但参数必须是字符串。
你必须写
set isUpdate to button returned of (display dialog ... )
推荐阅读
- python - 添加一个浮点数,我得到一个错误
- r - 如何在 R 中多次复制此功能?
- git - 如何将我的分支推送到现有的 Github 仓库而不将其合并到 master?
- python-3.x - 基本身份验证在 python 中不起作用
- android - ALTbeacon 在 Android 模块中的使用
- variables - 等待执行后异步/等待结果为空
- asp.net-mvc - 有没有办法使用 Identity 2.0 AspNetUsers Authentication (Azure SQL) 和 OpenIdConnect(使用 Azure Active Directory)?
- sql - 将数字和字符串的串联转换为日期
- python - 将外键序列化为 DRF 中的列表
- c++ - 在 C++ 后缀上测试太多操作数以中缀堆栈