Skip to content Skip to sidebar Skip to footer

Why 'os.system' Exits With Return Code 1?

I want to execute some adb commands from python script. But when i executed the following line os.system('adb devices') The cmd returns with 1 instead of 0. I also tried executing

Solution 1:

According to Windows docs, you've got 1, because there was an error on your command.

Maybe use subprocess could be a better approach.

import subprocess

subprocess.check_output(
    "adb devices", 
    stderr=subprocess.STDOUT,
    shell=True)

Post a Comment for "Why 'os.system' Exits With Return Code 1?"