Shell 如何将函数和变量传递给自动机输入?
我有一个这样的函数Shell 如何将函数和变量传递给自动机输入?,shell,input,automator,Shell,Input,Automator,我有一个这样的函数 myText(){ echo "Title: ${1}" echo "Text: ${2}" } title="ABC" text="123" document=/tmp/temp.txt myText "${title}" "${text}" while read line; do fillText "${title}" "${text}" done < "${document}" 所以我试着: while read line; do
myText(){
echo "Title: ${1}"
echo "Text: ${2}"
}
title="ABC"
text="123"
document=/tmp/temp.txt
myText "${title}" "${text}"
while read line; do
fillText "${title}" "${text}"
done < "${document}"
所以我试着:
while read line; do
output=$(fillText "${title}" "${text}")
automator -i "${output}" ~/Library/Services/myAutomator.workflow
done < "${document}"
读行时;做
输出=$(填充文本“${title}”“${text}”)
自动机-i“${output}”~/Library/Services/myAutomator.workflow
完成<“${document}”
它不起作用。你们中有谁知道怎么做吗
PS:输出有多行。告诉
自动程序
通过-
作为-i
的参数读取标准输入
while read line; do
fillText "${title}" "${text}" | automator -i - ~/Library/Services/myAutomator.workflow
done < "${document}"
读行时;做
fillText“${title}”“${text}”| automator-i-~/Library/Services/myAutomator.workflow
完成<“${document}”
Mh。我希望它看起来那么容易和轻松。但是,它与我的脚本不兼容(请参阅)。也许是env bash
?它是如何失败的?您使用什么操作读取输入?我更新了要点,使其在没有我传递给它的输入的情况下工作。问题是,即使在添加verbose选项时,我也没有得到任何错误输出。文本文件的内容是一个简单的标记链接,如*[Title](http://stackoverflow.com)
。
while read line; do
output=$(fillText "${title}" "${text}")
automator -i "${output}" ~/Library/Services/myAutomator.workflow
done < "${document}"
while read line; do
fillText "${title}" "${text}" | automator -i - ~/Library/Services/myAutomator.workflow
done < "${document}"