Skip to content

Instantly share code, notes, and snippets.

@justMaku
Created January 7, 2020 11:50
Show Gist options
  • Save justMaku/b3597bdf633c648323127d9ac4ba14bf to your computer and use it in GitHub Desktop.
Save justMaku/b3597bdf633c648323127d9ac4ba14bf to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# dump the contents of all toplevel keys in scutil's toplevel list.
#
import subprocess
import re
def run_command_with_input(command, input):
popen = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
(stdout, stderr) = popen.communicate(input)
return stdout
scutil_script = 'list\n'
stdout = run_command_with_input('/usr/sbin/scutil', scutil_script)
keys = re.findall(r'subKey \[\d+\] = (.+)', stdout)
for key in keys:
scutil_script = 'show {}\n'.format(key)
print '\n====== {} ======'.format(key)
print run_command_with_input('/usr/sbin/scutil', scutil_script)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment