changeset 49:8926b72d828e

first success with pipe
author catherine@localhost
date Fri, 06 Jun 2008 16:51:09 -0400
parents 34fb41095451
children dccf27f52f51
files cmd2.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Tue Jun 03 15:26:54 2008 -0400
+++ b/cmd2.py	Fri Jun 06 16:51:09 2008 -0400
@@ -244,9 +244,10 @@
             statekeeper = Statekeeper(self, ('stdout',))            
             redirect = subprocess.Popen(redirect, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
             self.stdout = redirect.stdin
-            stop = cmd.Cmd.onecmd(self, statement)            
+            stop = cmd.Cmd.onecmd(self, statement)
             statekeeper.restore()            
-            self.stdout.write(redirect.stdout.read())
+            for result in redirect.communicate():
+                self.stdout.write(result or '')
             return stop # didn't record in history
         else:
             statement, redirect, mode = self.parseRedirectors(statement)