Archive for September 2006
Get Login Name from Python
[tags]python[/tags]
I was writing a script for the OCF and I found that I needed to access the login name of the user. Thankfully Python has a builtin library to do so.
>>> import os
>>> import pwd
>>> pwd.getpwuid(os.getuid())[0]
'abhi'
>>> pwd.getpwnam('abhi')
('abhi', '********', 501, 501, 'Kesava Yerra', '/Users/abhi', '/bin/bash')