Here is my code:
from subprocess import check_output
print check_output('whoami', shell=True)
This works fine.
However, if I put a command that isnt' existent it will say:
raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command 'test' returned non-zero exit status 1
When if you were to run this on your shell, it would say something like:
'test' isnot recognized as an intenral or external command, operable program or batch file.
How can I get this instead?
check_callwhich gives you a clear indication of a failure instead of having to look at the text. As to your question -- if you want the shell, use theshell.proc = subprocess.Popen('test', shell=True)