Le 16/08/2011 17:56, Alexander Kapps a écrit :
On 16.08.2011 16:57, smain kahlouch wrote:
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
... retur
On 16.08.2011 16:57, smain kahlouch wrote:
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
On 8/16/2011 10:57 AM, smain kahlouch wrote:
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')
realuse
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')
Traceba
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 li
On Tue, Aug 16, 2011 at 12:45 AM, smain kahlouch wrote:
> Hi all,
>
> I'm learning the python language and i'm trying to create a user if it is
> not found in the system.
> I figured it out by doing the following thing :
>
def finduser(user):
> ... for line in open('/etc/passwd'):
> ...
Hi all,
I'm learning the python language and i'm trying to create a user if it is
not found in the system.
I figured it out by doing the following thing :
>>> def finduser(user):
... for line in open('/etc/passwd'):
... if line.startswith(user):
... print user,