程序开始运行后输入重定向

时间:2018-04-22 16:23:05

标签: bash pipe io-redirection

程序启动后有没有办法使用输入重定向?

例如,我想运行一个程序,从中抓取一些数据,然后使用该数据将其+一些静态数据(从文件)推送到std输入:

1    ./Binary
2    Hello the open machine is: computer2
3    Which computer:command do you want to use:  
4    <<< "computer2:RunWaterPlants" 

我想使用第2行的某些程序输出重定向第4行。

我已经尝试过了(Keeping a bash script running along the program it has started, and sending the program input),但它会继续执行程序,而不会等待我的输入。

注意:我无法编辑./Binary

先谢谢!

编辑:所以我找到了这个Write to stdin of a running process using pipe,它适用于我要问的内容,但是1)当我用管道运行它时,我看不到stdout。

EDIT2:弄清楚了!所以它并不完美,但我从这个Writing to stdin of a process线程中找到了它。几乎我开始使用fifo管道并写信给它并让它听取输入。如果你遇到同样的问题,请查看它。

1 个答案:

答案 0 :(得分:0)

我是从 Writing to stdin of a process 中发现的。我几乎启动了一个 fifo 管道并写信给它,让它监听输入。