The pythonic way equal to "whoami"
Cameron Simpson
cs at zip.com.au
Thu Jun 9 00:28:22 EDT 2011
On 07Jun2011 20:22, Nitin Pawar <nitinpawar432 at gmail.com> wrote:
| import getpass
| user = getpass.getuser()
|
| On Tue, Jun 7, 2011 at 7:54 PM, TheSaint <nobody at 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 at 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_
More information about the Python-list
mailing list