Wrapping A Shell



I'm not sure if this is really the right place to ask this question, but
since the implementation is in Python, I figured I'd give it a shot.

I want to "wrap" a shell process using popen inside of python program
rather than creating a new shell process for each line I process in the
app. For example, the code might look like:


std = stdin, stdout, stderr = os.popen3("bash")

print >> stdin, "ls"

print stdout.readline()

However, it appears my understanding of popen (or perhaps buffered IO)
is off somewhere, because this certainly doesn't work anything like I
expect it to (it hangs on stdout.readline).

Obviously the example above is very contrived, but eventually I'll be
using this in an OpenGL "terminal" widget. Am I approaching this the
wrong way?

.



Relevant Pages

  • Re: Wrapping A Shell
    ... I want to "wrap" a shell process using popen inside of python program ... Here is a possible way to solve the problems with subprocess (unix ... only) and non blocking IO. ...
    (comp.lang.python)
  • Re: Wrapping A Shell
    ... since the implementation is in Python, I figured I'd give it a shot. ... I want to "wrap" a shell process using popen inside of python program ...
    (comp.lang.python)
  • Re: 3D plotting library / OpenGL
    ... > for user selection that works under OpenGl, ... Attach the CMake disk image and install the package. ... Toggle VTK_USE_HYBRID on. ... It should have found your framework Python. ...
    (comp.lang.python)
  • Scoping bugs in an embedded Python interpreter - Wizards please
    ... So every now and then I like to mess around with hobby projects - I ... often end up trying to write an OpenGL video game. ... Embedding Python into an OpenGL skeleton just seemed like ...
    (comp.lang.python)
  • Re: I see advice on how to debug a python module that hangs up the process
    ... >> The first step I'd suggest is to sprinkle print statements all around ... >> later perusal) and see when the thing hangs. ... You could also run python with -u so you're sure to get all the output flushed immediately, ... >>> def ptrace: ...
    (comp.lang.python)