I am trying to use the subprocess
to execute a command socat
. It just echos the command as 'show stat | socat unix-connect:/users/viperias/Applications/haproxy.stat stdio'
rather than printing the output of the command. It perfectly works for the other commands. Am I missing something?
def main():
cmd = "echo show stat | socat unix-connect:/users/viperias/Applications/haproxy.stat stdio"
ps = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
output = ps.communicate()[0]
print (output)
main()