In the Perl language, you can fork a child process with the following syntax

open CHILD, " | programA | programB | program C";
print CHILD "this is an example input";

(at least, you can do this under linux). This statement starts 3 processes in fact; programA, B and C. Moreover, the stdout of A is piped to the stdin of B and the stdout of B is piped to the stdin of C, forming a pipeline. Since the command starts, with a "|", CHILD is a pipe through which your program can write in the stdin of A.

I'd like to know if a similar construct exists for python, or, suppose I want to achieve the same effect with python, what would be the best way to do it ?

Thanks, it works very well this way

import subprocess
child = subprocess.Popen( " progA | progB  |  progC",
  shell = True,
  stdin = subprocess.PIPE,
)
child.stdin.write("example input\n")

Thanks for the feedback.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.