I'm trying to run bash code via python. Normal statements (netstat, for example) work. If functions like the one below, however, don't. What should I change in order to run the following code correctly? Thanks in advance
>>> import os
>>> import subprocess
>>>
>>> os.setenv['a']='test'
>>> _c = 'if [ "$a" == "test" ]; then echo $a; fi'
>>> print(subprocess.Popen(_c, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8'))
/bin/sh: 1: [: anto: unexpected operator