Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.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
Bash 通过stdin多次向shell脚本传递参数_Bash_Stdin - Fatal编程技术网

Bash 通过stdin多次向shell脚本传递参数

Bash 通过stdin多次向shell脚本传递参数,bash,stdin,Bash,Stdin,我有一个脚本StartProcess.sh,它接受stdin-3中的两个选项和一个文件名test.xml 如果我运行下面的脚本,它将正确执行,并再次等待输入。 我想以某种方式通过3和test.xmln次StartProcess.sh。我如何做到这一点 ./StartProcess.sh << STDIN -o other --options 3 test.xml STDIN /StartProcess.sh您可以运行循环,在循环中传递参数的次数与在管道上运行脚本的次数相同。这样,

我有一个脚本
StartProcess.sh
,它接受
stdin
-
3
中的两个选项和一个文件名
test.xml

如果我运行下面的脚本,它将正确执行,并再次等待输入。 我想以某种方式通过
3
test.xml
n
StartProcess.sh
。我如何做到这一点

./StartProcess.sh << STDIN -o other --options 
3
test.xml
STDIN

/StartProcess.sh您可以运行循环,在循环中传递参数的次数与在管道上运行脚本的次数相同。这样,脚本只启动一次,参数通过stdin发送任意次数

count=3
for (( iter = 0; iter < 3; iter++ )); do
    echo "3" "test.xml"
done | StartProcess.sh
count=3
对于((iter=0;iter<3;iter++);做
echo“3”“test.xml”
完成|开始进程。sh
但是我不能完全确定您是想通过文本字符串
test.xml
作为参数还是文件内容