Created
January 7, 2020 11:50
-
-
Save justMaku/b3597bdf633c648323127d9ac4ba14bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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