Last active
October 3, 2017 03:19
-
-
Save arubdesu/98231ad6a7575b3239ce to your computer and use it in GitHub Desktop.
dscl+python for common tasks
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/python | |
import subprocess | |
cmd = '/usr/bin/dscl', '.', 'list', '/Users' | |
task = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
(out, err) = task.communicate() | |
allusers = (out).split() | |
nonsyss = [] | |
syss = ['jssadmin', 'root', 'puppet', 'daemon', 'nobody', 'Guest', 'jenkins'] | |
for user in allusers: | |
if (not user[0] == '_') and (user not in syss): | |
nonsyss.append(user) | |
print nonsyss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the help. I ended up using bash instead.
https://gist.github.com/3a8cf25e91fa01cf3ee3.git