where a symlink points to

John Vetterli jvetterli-zC6tqtfhjqE at public.gmane.org
Mon Jun 21 00:53:46 UTC 2004


On Sun, 20 Jun 2004, Alexey Kutin wrote:
> 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' ;)

For C, you can use the lstat function to determine if a pathname is a
symlink, then use the readlink function to determine where it points to.

man 2 lstat
man 2 readlink
http://www.gnu.org/software/libc/manual/html_node/Symbolic-Links.html

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