Forcing Python to detect DocumentRoot

Michael Torrie torriem at gmail.com
Mon Jan 21 16:46:35 CET 2013


On 01/18/2013 06:02 AM, Ferrous Cranus wrote:
> Yes my Python scripts exist in a linux web host.
> 
> os.environ['HOME'] will indeed give the home directory of the user.
> 
> to me /home/nikos/
> 
> but i want a variable to point to
> 
> /home/nikos/public_html whice is called DocumentRoot.

Not it's not.  There is nothing in the operating system that defines this.

> is there avariable for that? i can't seem to find any...

Not there's nothing in the operating system that specifies this.  This
is a convention that makes sense only to the apache daemon itself.  If
your python script is running as a CGI script, then apache will set
environment variables that you can read with the os module.  See the
Apache docs for information on this.




More information about the Python-list mailing list