[clug] Python question Re setuid()
Darren Freeman
daz111 at rsphysse.anu.edu.au
Fri Jan 16 00:47:57 GMT 2004
On Fri, 2004-01-16 at 11:26, Leigh Makewell wrote:
> Hi guys.
> So does anyone know how to get the userid for a given username?
>
> I suppose I could parse the passwd file, but thats just a pain in the
> butt :)
Not really, I think an awk script would do the trick, or even a shell
script. Set your delimiter to ':' and the first entry is the username.
Awk will find that no problems. Then the third entry is the uid.
The following line entered at a shell will print my UID:
gawk -F ':' '/dfreeman:*/ {print $3}' </etc/passwd
> Leigh Makewell
Have fun,
Darren
More information about the linux
mailing list