On Tue, 08 Feb 2005 12:29:48 -, Bob Parnes <[EMAIL PROTECTED]> wrote:
> I have a python program on a server of an all-linux network. It needs to
> record the user name running it. Is there a way for the program to extract
> the name from the system without a separate log-in dialog?
>
> Bob Pa
Gerhard Haering wrote:
os.getuid() will give you the user id, but I don't know if Python has
methods to look up more information from that from /etc/passwd or
whereever from.
>>> import pwd,os
>>> pwd.getpwuid(os.getuid())
('michael', 'x', 1234, 100, 'Michael Str\xf6der', '/home/michael',
'/bin/ba
On Tue, Feb 08, 2005 at 12:29:48PM -, Bob Parnes wrote:
> I have a python program on a server of an all-linux network. It needs to
> record the user name running it. Is there a way for the program to extract
> the name from the system without a separate log-in dialog?
os.environ["USER"] for a
how about:
import getpass
getpass.getuser()
'gromit'
Hmm, yours is better. It also works on Windows. :-)
I wonder why os.getuser() does not work in Windows - apparently there is
a good implementation for Windows.
--
_
Bob Parnes wrote:
I have a python program on a server of an all-linux network. It needs to
record the user name running it. Is there a way for the program to extract
the name from the system without a separate log-in dialog?
Bob Parnes
What about:
import os
username = os.getlogin()
Please see
Bob Parnes wrote:
>I have a python program on a server of an all-linux network. It needs to
> record the user name running it. Is there a way for the program to extract
> the name from the system without a separate log-in dialog?
how about:
>>> import getpass
>>> getpass.getuser()
'gromit'
I have a python program on a server of an all-linux network. It needs to
record the user name running it. Is there a way for the program to extract
the name from the system without a separate log-in dialog?
Bob Parnes
--
Bob Parnes
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/p