Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:edu.au': 0.07; 'stuff,': 0.07; 'suggestion.': 0.09; 'variables,': 0.09; 'pm,': 0.10; 'wrote:': 0.14; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'nitin': 0.16; 'privileges.': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'subject:pythonic': 0.16; 'cc:addr:python-list': 0.17; 'tue,': 0.17; 'cheers,': 0.19; 'header:In-Reply-To:1': 0.21; 'science.': 0.22; 'cc:no real name:2**0': 0.23; 'trying': 0.23; 'import': 0.29; 'cc:addr:python.org': 0.30; 'environment': 0.30; 'it.': 0.31; 'regardless': 0.34; 'header:User-Agent:1': 0.35; 'cc:2**1': 0.35; 'charset:us-ascii': 0.36; 'received:au': 0.37; 'run': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'user': 0.39; 'called': 0.39; "i'd": 0.39; 'dangerous': 0.65; 'received:202': 0.66; 'subject:The': 0.69; 'database.': 0.72; 'cameron': 0.73; 'username': 0.73 Date: Thu, 9 Jun 2011 14:28:22 +1000 From: Cameron Simpson To: Nitin Pawar Subject: Re: The pythonic way equal to "whoami" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) References: Cc: python-list@python.org, TheSaint X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1307594067 news.xs4all.nl 49044 [::ffff:82.94.164.166]:49804 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7271 On 07Jun2011 20:22, Nitin Pawar wrote: | import getpass | user =3D getpass.getuser() |=20 | On Tue, Jun 7, 2011 at 7:54 PM, TheSaint wrote: | > I was trying to find out whose the program launcher, but os.environ['US= ER'] | > returns the user whom owns the desktop environment, regardless the prog= ram | > is called by root. | > I'd like to know it, so the program will run with the right privileges. [...] =46rom 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, --=20 Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Dangerous stuff, science. Lots of us not fit for it. - H.C. Bailey, _The Long Dinner_