| | |
Opening pipelines with python ?
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
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: 128
Reputation:
Solved Threads: 31
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
Views: 529 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Python
anti array avogadro beginner builtin clear client code color count csv curved def dictionary dynamic enter examples excel file float format frange ftp function gui heads homework import input java lapse line lines linux list lists loop microcontroller mouse multiple mysqldb mysqlquery newb number numbers output parsing path port prime program programming projects py2exe pygame pygtk pyopengl pyqt python random raw_input recursion recursive redirect script scrolledtext singleton software sqlite ssh stderr string strings subprocess sum syntax table terminal text thread threading time tkinter tlapse tooltip tuple tutorial twoup ubuntu unicode unix urllib urllib2 variable web-scrape wikipedia windows word wx.wizard wxpython





