Find the answer to your Linux question:
Results 1 to 9 of 9
Hi, How exactly can I make the output of one program, the input of another program? Thanks!...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    REL
    REL is offline
    Just Joined!
    Join Date
    Apr 2004
    Posts
    4

    Pipes question


    Hi,
    How exactly can I make the output of one program, the input of another program?


    Thanks!

  2. #2
    Just Joined!
    Join Date
    Sep 2003
    Posts
    83
    Hi REL,

    You can do this by using the pipe operator "|" (the vertical bar key on your keyboard). The general syntax is:

    Code:
    $ command1 | command2
    What happens is the standard output for command1 is piped to as the input for command2. For example, if you want to display a text file page by page on your terminal screen, you can do the following command:

    Code:
    $ cat {filename} | more

  3. #3
    REL
    REL is offline
    Just Joined!
    Join Date
    Apr 2004
    Posts
    4
    Thanks, but this outputs the text the the second program only when the first program is terminated...
    I want the two programs run at the same time... and every character that the first program outputs immedietlly "becomes" the input of the second program, while the first program is still running.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Sep 2003
    Posts
    83
    Hi,

    Can you post what program you need to run and what output you are expecting?

  6. #5
    REL
    REL is offline
    Just Joined!
    Join Date
    Apr 2004
    Posts
    4
    The two programs are not important... they are programs wich i wrote for my own needs in C...
    One is a console program (the "engine") and one is a GUI of that console program...
    I want them to communicate with each other so I thought this would be a good way... maybe im wrong.. :\
    Anyway, is what I asked for possible?

  7. #6
    Just Joined!
    Join Date
    Sep 2003
    Posts
    83
    In your case, an example of what you can do is, run the "engine" program from your GUI. Save the output of the "engine" program and let your GUI program read and display the output.

  8. #7
    Just Joined!
    Join Date
    Sep 2003
    Posts
    83
    If the "engine" program is a daemon which can communicate via sockets or IPC then you can use these methods to "talk" to the "engine"

  9. #8
    REL
    REL is offline
    Just Joined!
    Join Date
    Apr 2004
    Posts
    4
    Quote Originally Posted by kihbord
    In your case, an example of what you can do is, run the "engine" program from your GUI. Save the output of the "engine" program and let your GUI program read and display the output.
    Thats what I want to do.
    But how exactly do I do that? :\

  10. #9
    Just Joined!
    Join Date
    Sep 2003
    Posts
    83
    One suggestion would be to use the exec() function in C to run the external program.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •