Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7271
| Date | 2011-06-09 14:28 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: The pythonic way equal to "whoami" |
| References | <BANLkTikvt1tr+Ov8sVi3LdzOoxxHKiTQeQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.41.1307594067.11593.python-list@python.org> (permalink) |
On 07Jun2011 20:22, Nitin Pawar <nitinpawar432@gmail.com> wrote:
| import getpass
| user = getpass.getuser()
|
| On Tue, Jun 7, 2011 at 7:54 PM, TheSaint <nobody@nowhere.net.no> wrote:
| > I was trying to find out whose the program launcher, but os.environ['USER']
| > returns the user whom owns the desktop environment, regardless the program
| > is called by root.
| > I'd like to know it, so the program will run with the right privileges.
[...]
From the getuser() doco:
Get the username from the environment or password database.
First try various environment variables, then the password database
So, no, wrong suggestion.
Cheers,
--
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/
Dangerous stuff, science. Lots of us not fit for it.
- H.C. Bailey, _The Long Dinner_
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: The pythonic way equal to "whoami" Cameron Simpson <cs@zip.com.au> - 2011-06-09 14:28 +1000
csiph-web