I am trying to get status of postfix in my centos machine. There is a simple command called "postfix status" which returns status of postfix whether its on or off.
This it the minimal python code I came up with after going through previous answers. I've gone through this link : stack overflow link
import subprocess
op = subprocess.run(['postfix', 'status'], stdout=subprocess.PIPE)
print("output is :",op)
The output I am getting is somewhat different than expected
postfix/postfix-script: the Postfix mail system is not running
output is : CompletedProcess(args=['postfix status'], returncode=1, stdout=b'')
It seems like my python script isn't capturing the output. And output gets printed on terminal instead of being fed in to my script. What am I doing wrong? Extra Info: I tried replacing "postfix","status" with "ls","-l" in my script, and it seems to work fine, is there issue with how the command postfix status works?