Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Is there a standard module library function to access /etc/passwd or /etc/group

Reply
Thread Tools

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

 
 
Robin Cull
Guest
Posts: n/a
 
      07-30-2003
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
 
Reply With Quote
 
 
 
 
Heather Coppersmith
Guest
Posts: n/a
 
      07-30-2003
On 30 Jul 2003 05:16:43 -0700,
http://www.velocityreviews.com/forums/(E-Mail Removed) (Robin Cull) wrote:

> ... 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

--
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Gerhard_H=E4ring?=
Guest
Posts: n/a
 
      07-30-2003
Robin Cull wrote:
> 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

 
Reply With Quote
 
Robin Cull
Guest
Posts: n/a
 
      07-30-2003
Heather Coppersmith <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> On 30 Jul 2003 05:16:43 -0700,
> (E-Mail Removed) (Robin Cull) wrote:
>
> > ... 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
 
Reply With Quote
 
Steven Taschuk
Guest
Posts: n/a
 
      07-31-2003
Quoth Andrew Dalke:
[...]
> When you're stuck because you don't know which module something
> might be in (eg, I was just looking for XMLRPC server code in
> xmlrpclib - wrong place!), try the full index at
> http://python.org/doc/current/lib/genindex.html


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

--
Steven Taschuk "The world will end if you get this wrong."
(E-Mail Removed) -- "Typesetting Mathematics -- User's Guide",
Brian Kernighan and Lorrinda Cherry

 
Reply With Quote
 
Andrew Dalke
Guest
Posts: n/a
 
      07-31-2003
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 Removed)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Standard Library SSL Module (was: Python OpenSSL library) geremy condra Python 0 06-14-2010 09:43 PM
Standard Library SSL Module (was: Python OpenSSL library) Michael Crute Python 0 06-14-2010 07:54 PM
add pexpect to the standard library, standard "install" mechanism. funkyj Python 5 01-20-2006 08:35 PM
How standard is the standard library? steve.leach Python 1 04-18-2005 04:07 PM
Re: Possible additions to the standard library? (WAS: Aboutstandard library improvement) Fredrik Lundh Python 0 02-04-2005 07:34 AM



Advertisments