0

Hello I want to read output of command which gives progress bar like output as show below

10% |**** | 3:56 ETA 

I tried with following code

import subprocess import sys proc = subprocess.Popen("command", shell=True, stdout=subprocess.PIPE) while True: line = proc.stdout.readline() if not line: break split = line.rstrip() print line print "\n" print "Done" 

This code reads output after completion of progress bar to 100%, but I want to read it at intermediate. Can any one help?

1
  • No its scalpel, file recovery tool Commented Jun 24, 2012 at 17:33

1 Answer 1

4

You're using readline() but the progress bar is all printed on one line, so readline() waits until the progress bar has been fully printed, as that is when a line break occurs. Try read(1) to get a character at a time.

Sign up to request clarification or add additional context in comments.

1 Comment

Hello thanks it working, but if I want to omit starting version lines that is printed by subprocess, how will I do that?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.