strange problem with os.getlogin

M

Michele Simionato

I am having a strange issue with os.getlogin on Mandrake 10:

$ python -c "import os; print os.getlogin()"
Traceback (most recent call last):
File "<string>", line 1, in ?
OSError: [Errno 2] No such file or directory

On another linux machine (Debian) instead it works as expected.
For the moment I am using os.popen("whoami").read() which works
but it is an hack :-(
Does anybody have an idea of the source of the problem?


Michele Simionato
 
A

Alex Martelli

Michele Simionato said:
I am having a strange issue with os.getlogin on Mandrake 10:

$ python -c "import os; print os.getlogin()"
Traceback (most recent call last):
File "<string>", line 1, in ?
OSError: [Errno 2] No such file or directory

On another linux machine (Debian) instead it works as expected.
For the moment I am using os.popen("whoami").read() which works
but it is an hack :-(
Does anybody have an idea of the source of the problem?

Try running that python -c under strace (with the appropriate flags set
to avoid excessive tracing... you really care about tracing 'open'
syscalls, maybe 'access' or 'readlink'...) to see what getlogin is
trying to open. On my Mandrake 9.2, it tries /var/run/utmpx, which
fails, then /var/run/utmp, which succeeds. I don't have a 10.0 handy to
try... (I had installed it on the 'toy machine' but then I installed
ubuntu on top of it recently;-).


Alex
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top