Robinson
Robinson

Reputation: 11

How I redirect python stdout to C stdin using pipelines in linux

I have a python script and I want to use the output of it to be the input of other C program. I want to use pipelines, sintax would be:

python_script.py | C_program

but I don't know how to redirect the pythons stdout to C stdin

Upvotes: 1

Views: 733

Answers (3)

Sodved
Sodved

Reputation: 8607

If its not working, maybe your python is writing to standard error and not standard output. If this is the case you need to:

( python_script.py 2>&1 ) | C_program

Upvotes: 0

mosg
mosg

Reputation: 12391

It seems that you doing all right.

For example, if I need to redirect scripts output to program input, I used such construction:

$ my_script.py | progr

with case if progr accepts arguments in you code.

Upvotes: 0

Anton
Anton

Reputation: 2693

Redirection is done by the shell. As long as python script writes to stdout and C_program reads from stdin it should work ok.

Upvotes: 1

Related Questions