Pipe output of two programs running in parallel to another program [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash 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









share|improve this 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'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 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















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









share|improve this 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'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 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













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









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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'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 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













  • 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 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








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











1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










Remove the semicolon from your lucky guess...






share|improve this answer



























    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...






    share|improve this answer
























      up vote
      1
      down vote



      accepted










      Remove the semicolon from your lucky guess...






      share|improve this answer






















        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Remove the semicolon from your lucky guess...






        share|improve this answer












        Remove the semicolon from your lucky guess...







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 17 at 10:28









        RudiC

        1,2167




        1,2167












            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?