LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   best practices for subprocs & pipes in python (http://www.linuxquestions.org/questions/programming-9/best-practices-for-subprocs-and-pipes-in-python-387298/)

bardinjw 11-28-2005 01:27 PM

best practices for subprocs & pipes in python
 
could some who keeps more up to date than i tell me what the current preferred way of running a sub process is in python?

should i be using os.popen, popen2, subprocess.Popen, etc?

and a similar question,

is it possible to create a pipe to just a shell, keeping it open for later commands?

i was trying to create a single object (e.g. shell) that i could read and write to, like a shell command line, something lie this

Code:

try:
    shell.write('command -to run')
    output = shell.readlines()
except:
    print 'this went wrong', shell.stderr

i tried this a few ways, and never could get all the pipes working. i either get file errors or it loops indefintely (atleast until i hit ctrl+c) while reading.


All times are GMT -5. The time now is 06:34 PM.