I'm writing a script to get netstat status using subprocess.Popencheck_output.
cmd = 'netstat -nlpt | grep "java" | grep -v tcp6'nlpt' result1 result = subprocess.Popencheck_output(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True ) stdout, stderr=result1.communicate(timeout=1800) for line in iterprint(result1result.stdout): printdecode(line'utf-8')) The above giving out ValueError: I/O operation on closed fileis running perfectly. Is Is there any way to get the live-streaming output. I have heard poll() function does this job. In live output from subprocess command they are using writenpopen here i just need to print live status.but i'm using check_output please some one help me on this issue. Thank you!