Pipe output of two programs running in parallel to another program [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
-2
down vote
favorite
This question already has an answer here:
combine output from two commands in bash
5 answers
I have two programs foo.sh
and bar.sh
both of which contain infite loops, produce continuous Output and should run in parallel. I would like to pipe the output of both those programs to a third program consumer
.
Initially I only had foo.sh
running and the piping was easy via
./foo.sh | ./consumer
But now I would like to add bar.sh
to also send its output to consumer
.
I have tried the things suggested in those answers (Answer 1, Answer 2) but they only seem to work for programs where one ends and the next gets started after the first one ends. I need them both to run in parallel.
This does not work, as it only pipes the output of foo.sh
and never starts bar.sh
:
( ./foo.sh ; ./bar.sh ) | ./consumer
This lucky guess gave me a syntax error:
( ./foo.sh & ; ./bar.sh & ) | ./consumer
pipe io-redirection background-process
marked as duplicate by Community⦠Aug 17 at 10:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
 |Â
show 1 more comment
up vote
-2
down vote
favorite
This question already has an answer here:
combine output from two commands in bash
5 answers
I have two programs foo.sh
and bar.sh
both of which contain infite loops, produce continuous Output and should run in parallel. I would like to pipe the output of both those programs to a third program consumer
.
Initially I only had foo.sh
running and the piping was easy via
./foo.sh | ./consumer
But now I would like to add bar.sh
to also send its output to consumer
.
I have tried the things suggested in those answers (Answer 1, Answer 2) but they only seem to work for programs where one ends and the next gets started after the first one ends. I need them both to run in parallel.
This does not work, as it only pipes the output of foo.sh
and never starts bar.sh
:
( ./foo.sh ; ./bar.sh ) | ./consumer
This lucky guess gave me a syntax error:
( ./foo.sh & ; ./bar.sh & ) | ./consumer
pipe io-redirection background-process
marked as duplicate by Community⦠Aug 17 at 10:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Did answer 1'scommand1 & command2; | ...
not work for you?
â Michael Homer
Aug 17 at 10:10
To me it seemed it was only piping the output of command1 but never starting command2, as command1 will run indefinitely.
â oh.dae.su
Aug 17 at 10:12
How did it seem that way? It doesn't do that, but that's not to say there wasn't some other issue that's your real problem.
â Michael Homer
Aug 17 at 10:14
ok sorry for the wording. It only pipes the Output of command1, command2 is never started. If I reverse them, I get it the other way around.
â oh.dae.su
Aug 17 at 10:17
1
Yeah, exactly, that's not how it works, so you do have a different problem.command1
runs in the background andcommand2
starts shortly after. Tryyes y & yes n ; | cat
and see. You may need to provide your actual commands for someone to help you.
â Michael Homer
Aug 17 at 10:19
 |Â
show 1 more comment
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
This question already has an answer here:
combine output from two commands in bash
5 answers
I have two programs foo.sh
and bar.sh
both of which contain infite loops, produce continuous Output and should run in parallel. I would like to pipe the output of both those programs to a third program consumer
.
Initially I only had foo.sh
running and the piping was easy via
./foo.sh | ./consumer
But now I would like to add bar.sh
to also send its output to consumer
.
I have tried the things suggested in those answers (Answer 1, Answer 2) but they only seem to work for programs where one ends and the next gets started after the first one ends. I need them both to run in parallel.
This does not work, as it only pipes the output of foo.sh
and never starts bar.sh
:
( ./foo.sh ; ./bar.sh ) | ./consumer
This lucky guess gave me a syntax error:
( ./foo.sh & ; ./bar.sh & ) | ./consumer
pipe io-redirection background-process
This question already has an answer here:
combine output from two commands in bash
5 answers
I have two programs foo.sh
and bar.sh
both of which contain infite loops, produce continuous Output and should run in parallel. I would like to pipe the output of both those programs to a third program consumer
.
Initially I only had foo.sh
running and the piping was easy via
./foo.sh | ./consumer
But now I would like to add bar.sh
to also send its output to consumer
.
I have tried the things suggested in those answers (Answer 1, Answer 2) but they only seem to work for programs where one ends and the next gets started after the first one ends. I need them both to run in parallel.
This does not work, as it only pipes the output of foo.sh
and never starts bar.sh
:
( ./foo.sh ; ./bar.sh ) | ./consumer
This lucky guess gave me a syntax error:
( ./foo.sh & ; ./bar.sh & ) | ./consumer
This question already has an answer here:
combine output from two commands in bash
5 answers
pipe io-redirection background-process
pipe io-redirection background-process
edited Aug 17 at 10:20
asked Aug 17 at 10:02
oh.dae.su
171118
171118
marked as duplicate by Community⦠Aug 17 at 10:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Community⦠Aug 17 at 10:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Did answer 1'scommand1 & command2; | ...
not work for you?
â Michael Homer
Aug 17 at 10:10
To me it seemed it was only piping the output of command1 but never starting command2, as command1 will run indefinitely.
â oh.dae.su
Aug 17 at 10:12
How did it seem that way? It doesn't do that, but that's not to say there wasn't some other issue that's your real problem.
â Michael Homer
Aug 17 at 10:14
ok sorry for the wording. It only pipes the Output of command1, command2 is never started. If I reverse them, I get it the other way around.
â oh.dae.su
Aug 17 at 10:17
1
Yeah, exactly, that's not how it works, so you do have a different problem.command1
runs in the background andcommand2
starts shortly after. Tryyes y & yes n ; | cat
and see. You may need to provide your actual commands for someone to help you.
â Michael Homer
Aug 17 at 10:19
 |Â
show 1 more comment
1
Did answer 1'scommand1 & command2; | ...
not work for you?
â Michael Homer
Aug 17 at 10:10
To me it seemed it was only piping the output of command1 but never starting command2, as command1 will run indefinitely.
â oh.dae.su
Aug 17 at 10:12
How did it seem that way? It doesn't do that, but that's not to say there wasn't some other issue that's your real problem.
â Michael Homer
Aug 17 at 10:14
ok sorry for the wording. It only pipes the Output of command1, command2 is never started. If I reverse them, I get it the other way around.
â oh.dae.su
Aug 17 at 10:17
1
Yeah, exactly, that's not how it works, so you do have a different problem.command1
runs in the background andcommand2
starts shortly after. Tryyes y & yes n ; | cat
and see. You may need to provide your actual commands for someone to help you.
â Michael Homer
Aug 17 at 10:19
1
1
Did answer 1's
command1 & command2; | ...
not work for you?â Michael Homer
Aug 17 at 10:10
Did answer 1's
command1 & command2; | ...
not work for you?â Michael Homer
Aug 17 at 10:10
To me it seemed it was only piping the output of command1 but never starting command2, as command1 will run indefinitely.
â oh.dae.su
Aug 17 at 10:12
To me it seemed it was only piping the output of command1 but never starting command2, as command1 will run indefinitely.
â oh.dae.su
Aug 17 at 10:12
How did it seem that way? It doesn't do that, but that's not to say there wasn't some other issue that's your real problem.
â Michael Homer
Aug 17 at 10:14
How did it seem that way? It doesn't do that, but that's not to say there wasn't some other issue that's your real problem.
â Michael Homer
Aug 17 at 10:14
ok sorry for the wording. It only pipes the Output of command1, command2 is never started. If I reverse them, I get it the other way around.
â oh.dae.su
Aug 17 at 10:17
ok sorry for the wording. It only pipes the Output of command1, command2 is never started. If I reverse them, I get it the other way around.
â oh.dae.su
Aug 17 at 10:17
1
1
Yeah, exactly, that's not how it works, so you do have a different problem.
command1
runs in the background and command2
starts shortly after. Try yes y & yes n ; | cat
and see. You may need to provide your actual commands for someone to help you.â Michael Homer
Aug 17 at 10:19
Yeah, exactly, that's not how it works, so you do have a different problem.
command1
runs in the background and command2
starts shortly after. Try yes y & yes n ; | cat
and see. You may need to provide your actual commands for someone to help you.â Michael Homer
Aug 17 at 10:19
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Remove the semicolon from your lucky guess...
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Remove the semicolon from your lucky guess...
add a comment |Â
up vote
1
down vote
accepted
Remove the semicolon from your lucky guess...
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Remove the semicolon from your lucky guess...
Remove the semicolon from your lucky guess...
answered Aug 17 at 10:28
RudiC
1,2167
1,2167
add a comment |Â
add a comment |Â
1
Did answer 1's
command1 & command2; | ...
not work for you?â Michael Homer
Aug 17 at 10:10
To me it seemed it was only piping the output of command1 but never starting command2, as command1 will run indefinitely.
â oh.dae.su
Aug 17 at 10:12
How did it seem that way? It doesn't do that, but that's not to say there wasn't some other issue that's your real problem.
â Michael Homer
Aug 17 at 10:14
ok sorry for the wording. It only pipes the Output of command1, command2 is never started. If I reverse them, I get it the other way around.
â oh.dae.su
Aug 17 at 10:17
1
Yeah, exactly, that's not how it works, so you do have a different problem.
command1
runs in the background andcommand2
starts shortly after. Tryyes y & yes n ; | cat
and see. You may need to provide your actual commands for someone to help you.â Michael Homer
Aug 17 at 10:19