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

Discussion in 'Python' started by Robin Cull, Jul 30, 2003.

  1. Robin Cull

    Robin Cull Guest

    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
     
    Robin Cull, Jul 30, 2003
    #1
    1. Advertising

  2. On 30 Jul 2003 05:16:43 -0700,
    (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
     
    Heather Coppersmith, Jul 30, 2003
    #2
    1. Advertising

  3. Re: Is there a standard module library function to access /etc/passwdor /etc/group

    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
     
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Jul 30, 2003
    #3
  4. Robin Cull

    Robin Cull Guest

    Heather Coppersmith <> wrote in message news:<>...
    > On 30 Jul 2003 05:16:43 -0700,
    > (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
     
    Robin Cull, Jul 30, 2003
    #4
  5. 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."
    -- "Typesetting Mathematics -- User's Guide",
    Brian Kernighan and Lorrinda Cherry
     
    Steven Taschuk, Jul 31, 2003
    #5
  6. Robin Cull

    Andrew Dalke Guest

    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
     
    Andrew Dalke, Jul 31, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kempniu
    Replies:
    1
    Views:
    546
    Jason A. Crome
    Feb 3, 2004
  2. Marco Herrn
    Replies:
    7
    Views:
    638
    Ng Pheng Siong
    Apr 9, 2004
  3. Iván Cabria
    Replies:
    0
    Views:
    309
    Iván Cabria
    Nov 4, 2004
  4. Steven Hansen

    Etc.passwd on OS X

    Steven Hansen, Oct 13, 2009, in forum: Ruby
    Replies:
    3
    Views:
    149
    Steven Hansen
    Oct 13, 2009
  5. Replies:
    4
    Views:
    186
    John W. Krahn
    Aug 3, 2005
Loading...

Share This Page