Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-26 Thread boB Stepp
Thanks Alan (and Mats)! It appears there are many ways to skin this cat! On Sat, Aug 26, 2017 at 2:21 AM, Alan Gauld via Tutor wrote: > >> My objective: Determine who the currently logged in user is and >> determine if that user is in my list of users that I have authorized

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-26 Thread Alan Gauld via Tutor
> My objective: Determine who the currently logged in user is and > determine if that user is in my list of users that I have authorized > to use my programs. In addition to Steve and Mats answers: import os os.getlogin() #-> 'alan' os.getuid() #-> 1001 import pwd pwd.getpwuid(os.getuid())

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-25 Thread boB Stepp
On Fri, Aug 25, 2017 at 8:33 PM, Steven D'Aprano wrote: > On Fri, Aug 25, 2017 at 07:13:12PM -0500, boB Stepp wrote: > >> My objective: Determine who the currently logged in user is > > py> import os > py> os.getlogin() > 'steve' Sweet! Much better. I did not scan the os

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-25 Thread Mats Wichmann
import getpass getpass.getuser () depending on how fussy you want to be... On August 25, 2017 6:13:12 PM MDT, boB Stepp wrote: >SunOS 5.10, Python 2.4/2.6 > >I ask forgiveness in advance as I cannot copy and paste into an email >what I am doing on this system. So I

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-25 Thread Steven D'Aprano
On Fri, Aug 25, 2017 at 07:13:12PM -0500, boB Stepp wrote: > My objective: Determine who the currently logged in user is py> import os py> os.getlogin() 'steve' > and > determine if that user is in my list of users that I have authorized > to use my programs. That's probably best handled at

[Tutor] How to use subprocess module to get current logged in user?

2017-08-25 Thread boB Stepp
SunOS 5.10, Python 2.4/2.6 I ask forgiveness in advance as I cannot copy and paste into an email what I am doing on this system. So I will have to manually type things, introducing the usual possibility of typos. My objective: Determine who the currently logged in user is and determine if that