In my script I was using this with decoding to utf-8:
result = subprocess.run(['command'], stdout=subprocess.PIPE).stdout.decode('utf-8')
Now I need to change command, where I need to use pipelines, so according to few examples which I have found, I need to use subprocess.Popen instead of subprocess.run. So I have something like this:
r1 = subprocess.Popen(['command1'], stdout=subprocess.PIPE)
r2 = subprocess.Popen(['command2'], stdin=r1.stdout, stdout=subprocess.PIPE)
r3 = subprocess.Popen(['command3'], stdin=r2.stdout, stdout=subprocess.PIPE)
result = r3.stdout
However, in this situation I can't add to the end stdout.decode('utf-8')
because I get error
AttributeError: '_io.BufferedReader' object has no attribute 'decode'
Could someone help me, how can I decode it to utf8?