Is there a standard module library function to access /etc/passwd or /etc/group

R

Robin Cull

Hi all,

I'm writing a script that needs to do lookups on the UNIX passwd and
groups file on textual usernames/group names and return numeric
UID/GID. Something that gives access to the C standard libarary
functions get[pw|group]ent(), for example. I've Googled around on
various logical search terms and looked through pydoc and the module
reference but haven't found anything up to this point. I'd have
thought that the os module would provide this sort of access. I did
find something called UserDBM but this appears not to be a standard
module.

Before I go away and write a couple of functions to do this myself,
can anyone tell me if there is a module that provides this sort of
interface? I'd really like it to be a standard module as the script
will have to run at a lot of different sites and I'm hoping there are
no external dependencies past an RPM installation of Python. If not,
I'll do my own local functions in the script.

Thanks all.

Cheers,

Robin
 
H

Heather Coppersmith

On 30 Jul 2003 05:16:43 -0700,
... Something that gives access to the C standard libarary
functions get[pw|group]ent(), for example ...

Right out of the table of contents of Python's Library Reference:

8.2 pwd -- The password database
8.3 grp -- The group database

When all else fails, read the manual.... ;-)

Regards,
Heather
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

Robin said:
Hi all,

I'm writing a script that needs to do lookups on the UNIX passwd and
groups file [...]

import pwd, grp

Next question? :)

-- Gerhard
 
R

Robin Cull

Heather Coppersmith said:
On 30 Jul 2003 05:16:43 -0700,
... Something that gives access to the C standard libarary
functions get[pw|group]ent(), for example ...

Right out of the table of contents of Python's Library Reference:

8.2 pwd -- The password database
8.3 grp -- The group database

Those'll be the ones! :)
When all else fails, read the manual.... ;-)

I assure you I did, in fact it baffles me that I missed "pwd" in the
global module index when I was scanning for "passwd". Then I went off
on a complete tangent and started looking through "os" and "posix" for
some reason. A case of "can't see the wood for the trees" I think!

I'll look harder next time ;)

Cheers,

Robin
 
A

Andrew Dalke

Steven Taschuk:
And don't forget the full-text searching capabilities at pydoc.org.

Can't forgot something I didn't know about ;)

Hmmm, my search for "xmlrpc server" fails but "xml-rpc server" is
successful.

Any idea when it'll be updated for 2.3?

Andrew
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top