Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7271 > unrolled thread
| Started by | Cameron Simpson <cs@zip.com.au> |
|---|---|
| First post | 2011-06-09 14:28 +1000 |
| Last post | 2011-06-09 14:28 +1000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: The pythonic way equal to "whoami" Cameron Simpson <cs@zip.com.au> - 2011-06-09 14:28 +1000
| From | Cameron Simpson <cs@zip.com.au> |
|---|---|
| Date | 2011-06-09 14:28 +1000 |
| Subject | Re: The pythonic way equal to "whoami" |
| Message-ID | <mailman.41.1307594067.11593.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web