import subprocess result = subprocess.run(['ls', '-l'], check=True) print(result.returnstatus)