The command is framed to determine if Xcode works on a Mac: cmd = "ps -ax | grep -v grep | grep Xcode"
If Xcode does not work, then the command above works well with Popenthe module method subprocess, but calls method CalledProcessErrorc check_output. I tried to check stderrfor the following code, but could not get the relevant information to understand the reason.
from subprocess import check_output, STDOUT, CalledProcessError
psCmd = "ps -ax | grep -v grep | grep Xcode"
o = None
try:
o = check_output(psCmd, stderr=STDOUT, shell=True)
except CalledProcessError as ex:
print 'Error:', ex, o
The exception message is as follows:
Error: Command 'ps -ax | grep -v grep | grep Xcode' returned non-zero exit status 1 None
Question: Why does the above command work with Popen, but with a check_output error?
Note. The team works well with both approaches if Xcode is running.
source
share