LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 11-28-2005, 01:27 PM   #1
bardinjw
Member
 
Registered: Apr 2003
Location: boston
Distribution: ubuntu debian redhat fedora
Posts: 108

Rep: Reputation: 15
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pipes in python? SciYro Programming 9 08-02-2006 10:35 AM
Superkaramba & Python iZvi Linux - Software 7 11-24-2004 04:57 PM
[Perl] brainstorming with pipes & commands patator Programming 3 06-25-2004 05:17 AM
Xchat & Python nixdisciple Linux - General 1 06-03-2002 05:54 AM
Python & Linux Relfx Linux - Newbie 1 08-17-2001 04:59 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration