chokingjaik
December 14th, 2018, 05:57 PM
Hello everyone and thanks in advance for any assistance provided. I'm attempting to list only usernames in terminal...then use that command in a python application. I've run into an issue, hopefully someone can provide assistance letting me know why it won't work or what I can do to get around it.
Why does this work in terminal:
eval getent passwd {$(awk '/^UID_MIN/ {print $2}' /etc/login.defs)..$(awk '/^UID_MAX/ {print $2}' /etc/login.defs)} | cut -d: -f1
But this does not work as python?:
#!/usr/bin/python3
import sys, os
def lisUser():
print ("This is a current list of users on this system: ")
os.system("eval getent passwd {$(awk '/^UID_MIN/ {print $2}' /etc/login.defs)..$(awk '/^UID_MAX/ {print $2}' /etc/login.defs)} | cut -d: -f1")
lisUser()
Why does this work in terminal:
eval getent passwd {$(awk '/^UID_MIN/ {print $2}' /etc/login.defs)..$(awk '/^UID_MAX/ {print $2}' /etc/login.defs)} | cut -d: -f1
But this does not work as python?:
#!/usr/bin/python3
import sys, os
def lisUser():
print ("This is a current list of users on this system: ")
os.system("eval getent passwd {$(awk '/^UID_MIN/ {print $2}' /etc/login.defs)..$(awk '/^UID_MAX/ {print $2}' /etc/login.defs)} | cut -d: -f1")
lisUser()