如何在 Applescript 中将一个 'do shell script' 的输出用于另一个
How to use output from one 'do shell script' for another one in Applescript
我正在使用 Mail.app 规则 (MacOS Mojave),该规则通过使用使用 'do shell script' 命令的 AppleScript 为选定的电子邮件消息创建 TaskWarrior 任务。
创建任务没有问题,但我想给任务添加注释,这需要您使用 shell 脚本的输出 - 即 "Created task [number]"。因为注释任务是以下 shell 脚本: task [number] annotate [your annotation, in my case a link to the email message].
我以为我设法从第一个 shell 脚本到 "task [number]" 得到了 "Created task [number]" 结果,这是第二个 shell 脚本的开始,但是结果现在没有指定命令 - 假设 'information'。
我试过使用延迟 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 注释。但我得到:
error "Mail got an error: No command specified - assuming
'information'. No matches." number 1
No command specified - assuming 'information'.
问问自己为什么 TaskWarrior 看不到命令是“annotate”。这是因为你的第二个命令语法错误。变化
& " annotate" &
到
& " annotate " &
注意 space。
我正在使用 Mail.app 规则 (MacOS Mojave),该规则通过使用使用 'do shell script' 命令的 AppleScript 为选定的电子邮件消息创建 TaskWarrior 任务。
创建任务没有问题,但我想给任务添加注释,这需要您使用 shell 脚本的输出 - 即 "Created task [number]"。因为注释任务是以下 shell 脚本: task [number] annotate [your annotation, in my case a link to the email message].
我以为我设法从第一个 shell 脚本到 "task [number]" 得到了 "Created task [number]" 结果,这是第二个 shell 脚本的开始,但是结果现在没有指定命令 - 假设 'information'。
我试过使用延迟 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 注释。但我得到:
error "Mail got an error: No command specified - assuming 'information'. No matches." number 1
No command specified - assuming 'information'.
问问自己为什么 TaskWarrior 看不到命令是“annotate”。这是因为你的第二个命令语法错误。变化
& " annotate" &
到
& " annotate " &
注意 space。