I've tried different methods to print the output of Popen
while command is being executed,none of them has worked for me so far,what am I missing?how to get real-time output using Popen
import signal, os
import sys
import subprocess
import argparse
from subprocess import Popen, PIPE, STDOUT
import threading
from time import sleep
import time
from subprocess import Popen, PIPE, STDOUT
cmd = "python \\\\snowcone\\builds724\\INTEGRATION\\BUILD-117493-STD.INT-1\\uncommon\\build\\script.exe -s ufs"
#proc = subprocess.Popen(cmd.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc = subprocess.Popen(cmd.split(' '), stderr=subprocess.PIPE)
print "Executing %s"%cmd
# Set the signal handler and a 5-second alarm
signal.signal(signal.SIGALRM, proc)
signal.alarm(5)
with proc.stderr:
for line in iter(proc.stderr.readline, b''):
print "LINE"
print line,
proc.wait() # wait for the subprocess to exit