os.getlogin() Error

Chris Angelico rosuav at gmail.com
Thu May 4 19:58:02 EDT 2017


On Fri, May 5, 2017 at 9:50 AM, Wildman via Python-list
<python-list at python.org> wrote:
> I'm afraid that won't work.  The user environment is different
> than root.  A different set of variables.  However you have
> given me a possible workaround.  You can't create a variable
> for root unless you are root so that approach is out.  But
> it might be possible to create the variable for the user
> and access it as root.  I don't have a lot of experience
> using os.environ, but I am going to at it closer.

When you start a subprocess, it inherits your environment. So you can
create an environment variable for yourself, then start the other
process.

But read Cameron's cautionary notes and basically just don't do this.

ChrisA



More information about the Python-list mailing list