Categories
Linux Mastering Development

Piping Multiple stdouts to Python program?

I have a program that prints in stdout and I’d like multiple instances of it where each instance’s stdout is piped to a sed and then the result(of three such sed) piped to a python program. I’m doing this

rtl_power -f 430M:434M:3.2M -g 30 -i 2 | sed -i '/2024-03-25/a \ dongle1' | python calc.py

and this works for one instance but now I am going to have 3 instances like

rtl_power -f 430M:434M:3.2M -g 30 -i 2 | sed -i '/2024-03-25/a \ dongle1' 
rtl_power -f 430M:434M:3.2M -g 30 -i 2 | sed -i '/2024-03-25/a \ dongle2' 
rtl_power -f 430M:434M:3.2M -g 30 -i 2 | sed -i '/2024-03-25/a \ dongle3' 

and I’d want all of them piped to the same instance of calc.py (at the same time) so I could do some calculations. PS FIFO and writing to files is not an option because I want the calculations done in real time, also rtl_power has streaming output

Leave a Reply

Your email address will not be published. Required fields are marked *