Finding the Current Working Directory
The current working directory when applied to CGI programs is:
- The default directory where the program will look for files when no directory path was specified with the file name.
- The base directory the program will assume when relative directory paths are specified.
For Unix/Linux servers, the current working directory usually is the directory where the CGI program is installed and running in.
But it's not always the case. Servers can be configured in a multitude of different ways.
When a CGI script doesn't find a file you know is where you specified it to be, it may be that the current working directory is not what you think it is.
The following short script can determine the current working directory for you.
(Master Pre-Installation Tester can be used instead if you prefer not to create your own testing script.)
Install the above script where CGI scripts can run (e.g. the cgi-bin). If testing for the current working directory that another script is using, install the above in the same directory as the other script.
Use a plain text word processor like NotePad or TextEdit when copying the above script and saving it to a file. Use an FTP program to upload the file to your server, uploading it as a plain text file, not as a binary file. Then give the uploaded file 755 permissions.
Type the URL of the script into your browser to obtain the current working directory.
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
©Copyright 2005 Bontrager Connection, LLC Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.