Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

resolving symbolic links in a pathname

by PerlDisciple (Novice)
on Nov 23, 2007 at 01:04 UTC ( [id://652465]=perlquestion: print w/replies, xml ) Need Help??

PerlDisciple has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

There's a resolvepath system call in Unix (man pages section 2, unistd.h on Solaris) that resolves all the symbolic links of its pathname argument. Does anyone know of a way, via CPAN module or otherwise, to get the same functionality in Perl?

Regards,
PerlDisciple

Replies are listed 'Best First'.
Re: resolving symbolic links in a pathname
by merlyn (Sage) on Nov 23, 2007 at 01:25 UTC
      Pardon the not-very-useful wild guess, but wasn't there a nice example program in some old Camel Book that would print out an output like
      /home/mjd/foo.c /home/mjd/bar/baz/foo.c /home/mjd/bar-1.0/baz/foo.c /userhomes/m/j/mjd/bar-1.0/baz/foo.c /mnt/homevol/m/j/mjd/bar-1.0/baz/foo.c
      as it progressively resolved the symlinks in higher and higher components of a path?

      I thought it might have been one of those abandoned items in the Perl source eg/ directory, but I couldn't find it there, so the Camel Book was my next guess.

      Addendum: This looks kinda interesting too.

        Yeah, in the pink Camel Book. I posted it here some time ago: Re: Following symlinks manually (historical code)

        ;-)

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      Thanks Randal.
Re: resolving symbolic links in a pathname
by dwu (Monk) on Nov 23, 2007 at 01:21 UTC
    Funny, Googling perl symbolic pathname turned up File::Find fairly quickly. See $File::Find::fullname in that document for something that sounds like it would work for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://652465]
Approved by randyk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (None)
    As of 2024-04-25 03:56 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found