pythonsubprocessapple-configurator

Translating Terminal Command to Subprocess Library


I'm trying to pull data from iOS devices that are attached to my Mac.

I have enabled the automation tool option in Configurator and am able to use cfgutil from terminal.

When I run the command cfgutil --format JSON -f get ECID in Terminal a JSON is returned with a "Devices" key that has a list of ECID's in the value.

When I try to run that command through a python script I keep getting errors.

getDevices = subprocess.check_output(["cfgutil", "--format JSON", "-f", "get", "ECID"])

returns "cfgutil: error: Unknown option '--format JSON'

Any idea what is preventing Terminal from just running the command and getting the output?


Solution

  • Every argument needs to be a separate list element, you can't put --format and JSON in the same string.

    getDevices = subprocess.check_output(["cfgutil", "--format", "JSON", "-f", "get", "ECID"])