473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
Jul 18 '05 #1
5 2348
On 30 Jul 2003 05:16:43 -0700,
ro********@pace.co.uk (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

Jul 18 '05 #2
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

Jul 18 '05 #3
Heather Coppersmith <me@privacy.net> wrote in message news:<m2************@host200-null.null.bellsouth.net>...
On 30 Jul 2003 05:16:43 -0700,
ro********@pace.co.uk (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
Jul 18 '05 #4
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."
st******@telusplanet.net -- "Typesetting Mathematics -- User's Guide",
Brian Kernighan and Lorrinda Cherry

Jul 18 '05 #5
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
da***@dalkescientific.com
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Raymond Hettinger | last post by:
Comments are invited on the following proposed PEP. Raymond Hettinger ------------------------------------------------------- PEP: 329
8
by: Felix Wiemann | last post by:
Hi! I want to create a module myproject.ui.curses, which needs to import the curses library. However, if I just write ``import curses``, the module imports *itself* instead of the standard...
2
by: F. Petitjean | last post by:
I have written a script to find the modules which export the largest number of names. The gc.getreferrers(*objs) function gives also an idea of the dependencies between the modules. The code...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
7
by: Alex | last post by:
Hi all, I've found a module that I think will help me combine fields properly, but I'm unsure how to add or use it with Access 2000. Below is the module I'd like to add: ...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
2
by: Godwin Burby | last post by:
Dear Pythoneer, I was just curious about using the cmd module for building my own command line interface. i saw a problem. The script is as follows: from cmd import Cmd import getpass class...
22
by: David Mathog | last post by:
One thing that keeps coming up in this forum is that standard C lacks many functions which are required in a workstation or server but not possible in an embedded controller. This results in a...
7
by: dm3281 | last post by:
Hello, I have this non-standard XML file that I have to manually sort thru each day and verify whether various jobs finish successfully or not. This file isn't a real XML file, so I cannot appear...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.