Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. subprocess stdout data
  2. def runCommand(commandLine):
  3.     print('############## Running command: ' + commandLine)
  4.     p = subprocess.Popen(commandLine, shell = True, stdout = subprocess.PIPE)
  5.     print (p.stdout.read().decode('utf-8'))
  6.        
  7. import subprocess
  8. proc = subprocess.Popen('cmake', shell=True, stdout=subprocess.PIPE)
  9. while proc.poll() is None:
  10.     output = proc.stdout.readline()
  11.     print output
  12.        
  13. # grep test test.txt
  14. test
  15.  ^
  16.  |
  17.  |------- this word is red
  18.        
  19. # grep test test.txt | cat
  20. test
  21.  ^
  22.  |
  23.  |------- no longer red
  24.        
  25. # grep test test.txt --color=always | cat
  26. test
  27.  ^
  28.  |
  29.  |------- red again
  30.        
  31. p.stdout.read
  32.        
  33. for line in p.stdout: