where a symlink points to
John Macdonald
john-Z7w/En0MP3xWk0Htik3J/w at public.gmane.org
Mon Jun 21 05:47:28 UTC 2004
On Sun, Jun 20, 2004 at 06:40:10PM -0700, Alexey Kutin wrote:
> Hi everyone,
>
> Is where a way to find a real path where a symlink leads to? Say, I have
> /www/domainx.com -> /usr/home/domainx.com
>
> how to get /usr/home/domainx.com from an application? I'm looking for
> a solution for Perl or C code. I mean a better one than parsing output of
> 'ls -l' ;)
>From perl, the readlink function returns the symlink
from a filename. It might be relative, or contain
components that are themselves symlinks, so you
may need to keep track of the directory path of the
original (to strip off the appropriate numnber of
directories for leading ../ entries in the symlink)
and test the intervening directory and final file
components for extra symlinks (both for the original
path and for new elements returned from readlink
calls).
--
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list