Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/137.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 如何将函数和变量传递给自动机输入?_Shell_Input_Automator - Fatal编程技术网

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}"