Following code will get command line output of executing another program:
import subprocess
p = subprocess.Popen('ls', stdout=subprocess.PIPE)
print p.communicate()[0]
But some programs like wget, ffmpeg will display a progress bar in command line, and update its value all the time, like this:
12% [--- ] 105,691 50.6K/s eta 1h 43m
I tried above code to get output of wget but it failed. it cannot get the output until wget finished executing, and the output is an empty string.