I'm writing a script to get netstat status using subprocess.Popen.
cmd = 'netstat -nlpt | grep "java" | grep -v tcp6'
result1 = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True )
stdout, stderr=result1.communicate()
for line in iter(result1.stdout):
print(line)
The above is giving ValueError: I/O operation on closed file.. Is there any way to get the live-streaming output. In live output from subprocess command they are using writen and readlines here i just need to print live status please some one help me on this issue. Thank you!