[BangPypers] in CGI using getcwd
scorpion032 at gmail.com
Tue Nov 24 08:22:27 CET 2009
Yes, os.getcwd() does not give the directory where your code is located, but
where the call happens from. Otherwise it would always point to the where
python is installed on your system.
In order to get the directory of where the code is, you should something
this_file = os.path.abspath(__file__)
this_dir = os.path.dirname(this_file)
On Tue, Nov 24, 2009 at 10:01 AM, Vivek Rajendran <vivekbest86 at yahoo.com>wrote:
> I'm facing a problem as follows in using os.getcwd() in CGI scripting
> (Linux FC2 ,FC11)
> For Ex:
> I'm having my web folder and index.py file in location
> Also, I have a test file info.txt in the same foobar folder.
> My index.py is not able to open the file and read it in tha folder.
> Instead it reads under '/' folder.
> When I did os.getcwd() surprisingly I'm getting '/' as the current
> folder irrespective of location wherever I run the script. Also, I tried
> os.environ['PWD']. Same is the problem.(In windows both the approaches are
> working properly)
> Is this a configuration issue? If then, please tell me which file I
> need to configure (like httpd.conf,python.conf) and how to do it?
> It will be of great help to me If anyone provides me a clear and
> working soluton.
> Thanks and Regards
> Vivek Rajendran
> View this message in context:
> Sent from the BangPypers - Bangalore Python Users Group mailing list
> archive at Nabble.com.
> BangPypers mailing list
> BangPypers at python.org
More information about the BangPypers