Writing a Program that Utilises Pipes in Linux

Programming, for all ages and all languages.
Post Reply
xmc
Posts: 1
Joined: Sat Nov 11, 2006 12:42 am

Writing a Program that Utilises Pipes in Linux

Post by xmc »

Hi,

I need to write a program for linux in c++ that pipes data to another application, basically I want to be able to do the following on the command line:

Code: Select all

<my app> <parameters> | <other program> <parameters>
The other program does not support reading files directly but it does have an --stdin parameter. I just need to know how I can send data to the other side of a pipe like above from within a c++ app.

Does myapp's stdout automatically get piped to the other programs stdin?

Cheers. :)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Oi... :P

What you are referring to are command-line pipes, which are defined as forwarding stdout of the former program to the stdin of the latter. Means, write to stdout / cout in your application, and you are fine.
Every good solution is obvious once you've found it.
Post Reply