where a symlink points to

Alexey Kutin akutin-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org
Tue Jun 22 03:47:38 UTC 2004


Thanks for all answers they finally led me to realpath function which does
the job and is available in Cwd module for Perl.

Good luck
Alex.

----- Original Message -----
From: "John Macdonald" <john-Z7w/En0MP3xWk0Htik3J/w at public.gmane.org>
To: <tlug-lxSQFCZeNF4 at public.gmane.org>
Sent: Sunday, June 20, 2004 10:47 PM
Subject: Re: [TLUG]: where a symlink points to


> 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

--
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