Ok than you. You're right but it doesn't help me : I replaced it : >>> def finduser(user): ... if pwd.getpwnam(user): ... print user, "user exists" ... return True ... return False ... >>> finduser('realuser') realuser user exists True >>> finduser('blabla') Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 2, in finduser KeyError: 'getpwnam(): name not found: blabla'
As you can see, i just want to look for a user and if it doesn't exist, an action is taken (create user). Maybe you have another way to do that check ? Thank you 2011/8/16 Christian Heimes <li...@cheimes.de> > Am 16.08.2011 10:04, schrieb Chris Rebert: > > You can replace the /etc/passwd parsing with a call to pwd.getpwnam(): > > http://docs.python.org/library/pwd.html#pwd.getpwnam > > You should replace it. /etc/passwd is not the only source for users. > /etc/nsswitch.conf may list more user and group sources like nis/yp, > LDAP and so on. > > Christian > > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list