| | |
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 |
abrupt accessdenied advanced ansi anti apache application approximation argv array backend beginner binary builtin calculator change command converter countpasswordentry csv curved dan08 def dictionary edit event file float format function google heads homework 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 pointer prime programming py2exe pygame pyopengl python random recursion redirect remote return reverse scrolledtext session software sprite statictext statistics string strings syntax terminal text thread threading time tlapse tuple twoup ubuntu unicode unit urllib urllib2 variable voip wordgame write wxpython





