Maya
Maya

Reputation: 81

Bidirectional pipes in ubuntu / C++

I have a network topology table stored in a textfile called (minlog.txt) that I piped into a python file which determines the nodes to be deleted and print them out.

Here's a screenshot of what I've done so far:

Now, I want to write a c++ code that: - opens a pipe to the previous python program - reads the output (stdout) of the python file

I thought about using fork to create a child process then inside of that I'll call pipe then exec (to read the stdout of python file).. but I'm not sure if this is the right way to do it.. Any suggestions?

Upvotes: 1

Views: 431

Answers (1)

Robᵩ
Robᵩ

Reputation: 168726

Assuming that your C++ program is named "prog", the command line you want is:

cat minlog.txt | python graph.py | prog

Or, equivalently but more efficiently:

python graph.py < minlog.txt | prog

Upvotes: 1

Related Questions