| | |
Opening pipelines with python ?
Thread Solved |
In the Perl language, you can fork a child process with the following syntax
(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 ?
perl Syntax (Toggle Plain Text)
open CHILD, " | programA | programB | program C"; print CHILD "this is an example input";
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 ?
Last edited by Gribouillis; Aug 15th, 2008 at 7:40 pm.
•
•
Join Date: Jun 2008
Posts: 122
Reputation:
Solved Threads: 30
You can use subprocess with shell on unix.
http://blog.doughellmann.com/2007/07...ubprocess.html
And
http://www.python.org/doc/current/li...ubprocess.html
http://blog.doughellmann.com/2007/07...ubprocess.html
And
http://www.python.org/doc/current/li...ubprocess.html
Thanks, it works very well this way
python Syntax (Toggle Plain Text)
import subprocess child = subprocess.Popen( " progA | progB | progC", shell = True, stdin = subprocess.PIPE, ) child.stdin.write("example input\n")
![]() |
Other Threads in the Python Forum
- Previous Thread: Identifying file types in python
- Next Thread: New to Python, help printing output of system calls
| Thread Tools | Search this Thread |
accessdenied advanced apache application argv array beginner book change command converter countpasswordentry csv curved dan08 def dictionary dynamic edit enter event examples file float format function google gui homework import inches input jaunty java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric obexftp output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pygtk pyopengl python random recursion redirect remote return reverse scrolledtext session simple skinning software sprite statictext string strings syntax terminal text threading time tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable voip wordgame wxpython





