How to determine what user and group a Python script is running as?

后端 未结 3 762
执笔经年
执笔经年 2021-01-01 11:10

I have a CGI script that is getting an \"IOError: [Errno 13] Permission denied\" error in the stack trace in the web server\'s error log.

As part of deb

3条回答
  •  独厮守ぢ
    2021-01-01 11:39

    os.getgid() and os.getuid() can be useful. For other environment variables, look into os.getenv. For example, os.getenv('USER') on my Mac OS X returns the username. os.getenv('USERNAME') would return the username on Windows machines.

提交回复
热议问题