Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Getting logical path from Perl?

by talexb (Chancellor)
on Mar 08, 2021 at 13:54 UTC ( [id://11129331]=note: print w/replies, xml ) Need Help??


in reply to Getting logical path from Perl?

If pwd -L gives you the answer you want, can you just grab that value when you need it?

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Replies are listed 'Best First'.
Re^2: Getting logical path from Perl?
by mathomp4 (Novice) on Mar 08, 2021 at 17:59 UTC

    The issue with pwd -L is that we don't always run these scripts from the bindir. So, we'd have to chdir to do so and:

    $ cat /discover/nobackup/mathomp4/MyTestScript/bin/test-pwd.pl #!/usr/bin/env perl use FindBin; use File::Basename; my $fvroot = dirname($FindBin::Bin); print "Using Bin: $fvroot\n"; my $fvroot2 = dirname($FindBin::RealBin); print "Using RealBin: $fvroot2\n"; chomp($pwdL = `pwd -L`); print "Current pwd -L: $pwdL\n"; chdir($fvroot); chomp($pwdL2 = `pwd -L`); print "After pwd -L: $pwdL2\n" $ /discover/nobackup/mathomp4/MyTestScript/bin/test-pwd.pl Using Bin: /gpfsm/dnb44/mathomp4/MyTestScript Using RealBin: /gpfsm/dnb44/mathomp4/MyTestScript Current pwd -L: /home/mathomp4 After pwd -L: /gpfsm/dnb44/mathomp4/MyTestScript

    So, it's not logical because the chdir didn't go to the logical path! That said, I haven't yet tested the Path::Tiny yet.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 09:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found