applescript - 如何将一个“do shell script”的输出用于Applescript中的另一个
问题描述
我正在使用 Mail.app 规则 (MacOS Mojave),该规则通过使用“执行 shell 脚本”命令的 AppleScript 为所选电子邮件创建 TaskWarrior 任务。
创建任务是没有问题的,但我想对任务进行注释,这需要您使用 shell 脚本的输出 - 即“已创建任务 [编号]”。因为注释任务是以下 shell 脚本:task [number] annotate [您的注释,在我的例子中是指向电子邮件消息的链接]。
我以为我设法将“创建的任务 [编号]”结果从第一个 shell 脚本转换为“任务 [编号]”,这是第二个 shell 脚本的开头,但现在结果是没有指定命令 - 假设'信息'。
我尝试使用延迟 1,以便一个 shell 脚本等待另一个完成,但无济于事。
这是具体的脚本:
tell application "Mail"
set selectedMessages to selection
set theMessage to item 1 of selectedMessages
set messageid to message id of theMessage
-- Make URL (must use URL-encoded values for "<" and ">")
set urlText to "message://" & "%3c" & messageid & "%3e"
set onderwerp to subject of theMessage
set DueDate to display dialog "Wat is de due date?" default answer "friday"
do shell script "/usr/local/bin/task add Email over " & onderwerp & " beantwoorden due:" & (text returned of DueDate) & " project:Work +email"
-- This all works as it should. A task is created with the email subject and a due date that I give it. However, from here something goes wrong
set task to the result
set laatste to rich text 1 thru -2 of task
set annotate to rich text 9 thru -1 of laatste
do shell script "/usr/local/bin/" & annotate & " annotate" & urlText
end tell
我预计输出将是任务 [number] 用消息的 urlText 进行注释。但我得到:
错误“邮件出现错误:未指定命令 - 假设为‘信息’。没有匹配项。” 1号
解决方案
未指定命令 - 假设为“信息”。
问问自己为什么 TaskWarrior 看不到命令是“注释”。这是因为您的第二个命令语法错误。改变
& " annotate" &
到
& " annotate " &
注意空间。
推荐阅读
- linux - 在 Ubuntu docker 容器上找不到 Vi 或 Vim
- bash - Makefile:在条件下使用命令输出
- c# - C# 校验和 CRC16 CCITT
- python - 将 Bot 部署到 Heroku 时如何解决 TypeError?
- reactjs - 如何在 Prismic React Client 中从富文本编辑器渲染标签?
- clang - 如何检索 LLVM 中函数调用期间传递的参数?
- java - 使用 remotewebdriver 创建与 selenium 4 的 devtools 会话
- vue.js - Vue没有从API中找到图像路径
- c# - Serilog PostgresSql 接收器中的 .NET Core 自定义列
- arduino - 如何从 RFID 卡读取数据,然后通过串行监视器用新数据覆盖它?