Page 1 of 1

Writing a Program that Utilises Pipes in Linux

Posted: Wed Dec 20, 2006 8:01 am
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. :)

Posted: Wed Dec 20, 2006 9:40 am
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.