Is there a way I can tell my code to use the hard paths ... exclusively?
If I understand correctly, you want to do a "typical" chdir (as a typical user) to put yourself into a directory via a symlinked path, and then be able to use a consistent path string from this point, even while invoking a sudo process.
Try something like this maybe:
#!/usr/bin/perl
use strict;
use warnings;
use Cwd;
my $startup_path = getcwd;
my $symlink_path = "some/symlink/path";
chdir $symlink_path;
my $working_path = getcwd;
printf( "Started in %s, chdir'd to %s, now in %s\n",
$startup_path, $symlink_path, $working_path );
I think it should be the case that the value of "$working_path" should always be the absolute, physical path, without any symlink component in it.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|