On 20 Aug., 15:14, Christian Joergensen <[EMAIL PROTECTED]> wrote:
> PeteDK wrote:
> > Hi.
>
> > I want to retreive the name of the currently logged in user on the OS
> > on which my django app lives.
> > Is this possible?
>
> You are aware that on most systems, more than one user is allowed to
> login concurrently?
>

I must admit. i didn't know that. :-(

>
> > i have looked into the python standard library, and a module named
> > getpass() however i cant get i to work:-(
>
> > i hope someone has a clever idea to solve this problem.
>
> > PS: and the webserver runs linux. :-)
>
> This will give you a list of the currently logged in users:
>
>  >>> import commands
>  >>> [line.split()[0] for line in
> commands.getoutput("/usr/bin/who").split("\n")]
> ['razor']
>
> /Christian
>
> --
> Christian Joergensenhttp://www.technobabble.dk

Thanks. it works great.

Now do you know how this list is sorted? If it is sorted by time of
login then it should be fine to just use the latest user in the list??
or is there some kind of problem here that i am not aware off?

again, thanks! :-) eller mange tak:-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to