I need to re-use a common cgi-bin subdirectory for a number of websites I'm developing on my server. So the logical method would be:
$ mkdir /www/common/cgi-bin $ cd /www/site1 $ ln -s /www/common/cgi-bin $ cd /www/site2 $ ln -s /www/common/cgi-bin
which works perfectly, EXCEPT that in order to extract site-specific parameters, the cgi scripts need to read files in each individual site's own directory structure. But when resolving relative paths (I can't use absolute because of the nature of the eventual deployment environments) or even the current directory itself, my Perl scripts consider themselves to be in the original directory, not the one it SHOULD think it's in. To clarify:
#!/usr/bin/perl # whereami.pl use Cwd; print(cwd / "\n");
$ cd /www/global/cgi-bin $ whereami.pl /www/global/cgi-bin $ cd /www/site1/cgi-bin $ whereami.pl /www/global/cgi-bin
Similarly, trying to open a file with a relative path from /www/site1/cgi-bin fails because Perl's trying to open it relative to /www/global/cgi-bin.
So, is there a way to either resolve the "correct" path to the current directory in this situation, or at least to persuade it to open files with relative paths as I need?
The problem seems to be as much related to the Linux filesystem as to Perl itself, as
$ cd /www/site1/cgi-bin $ ls ..
Shows the contents of /www/global, not /www/site1.
Thanks in advance for any suggestions.
In reply to Resolving correct directory path in a symlinked directory by beermad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |