巴什 - 如何将参数传递到通过重定向标准输入读剧本 [英] Bash - How to pass arguments to a script that is read via redirected standard input
问题描述
我想在扩大多一点<一个href=\"http://stackoverflow.com/questions/8514284/bash-how-to-pass-arguments-to-a-script-that-is-read-via-standard-input/8514351#8514351\">Bash - 如何将参数传递到通过后标准输入读剧本
I would like to expand a little more on "Bash - How to pass arguments to a script that is read via standard input" post.
我想创建一个脚本,需要标准输入和远程运行它,而传递参数给它。
I would like to create a script that takes standard input and runs it remotely while passing arguments to it.
这是我建立的脚本简化内容:
Simplified contents of the script that I'm building:
ssh server_name bash <&0
我如何采取接受的论点下面的方法,并将其应用到我的脚本?
How do I take the following method of accepting arguments and apply it to my script?
cat script.sh | bash /dev/stdin arguments
也许我这样做不正确,请提供替代解决方案,以及
Maybe I am doing this incorrectly, please provide alternate solutions as well.
推荐答案
试试这个:
cat script.sh | ssh some_server bash -s - <arguments>
这篇关于巴什 - 如何将参数传递到通过重定向标准输入读剧本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!