[sf-perl] Setting LD_LIBRARY_PATH
Li Sen
li at senweb.net
Thu Jul 5 19:22:03 PDT 2007
David Alban wrote:
> How about writing a wrapper around your program. The wrapper sets
> LD_LIBRARY_PATH (or for that matter, any environment variable you
> like), and then calls your program with all arguments it got?
>
> On 7/5/07, Loo, Peter # PHX <Peter.Loo at source.wolterskluwer.com> wrote:
>
>> Unix admins here are not happy about updating the .profile of the production
>> account to add two additional entries to LD_LIBRARY_PATH environment
>> variable. So I am having to figure out an alternative solution in setting
>> this environment dynamically during program run. I have tried setting it at
>> the beginning of the program and I have tried putting it in the BEGIN block
>> with no luck. I have searched the Internet and found a lot of discussion
>> but did not find any solution.
>>
>> According to Tim Bunce's posting, LD_LIBRARY_PATH must be set before the
>> process starts.
>>
>> http://groups.google.com/group/perl.dbi.users/browse_thread/thread/8de203f9ee4cb9a/579d2732c9712f1d?lnk=st&q=Perl+LD_LIbrary_path&rnum=7&hl=en#579d2732c9712f1d
>>
>> Shall I just go Tim's advise and have the admins change the .profile or does
>> someone have a solution to help with this problem?
>>
>
>
Or, you can add try this:
BEGIN {
my $additonal_path = '/whatever/path/you/want';
if (ENV{LD_LIBRARY_PATH} !~ m/$additonal_path/) {
$ENV{LD_LIBRARY_PATH} .= $additonal_path;
exec $0, @ARGV;
exit;
}
}
to re-invoke your script with the additional path(s) set.
Regards,
Li
More information about the SanFrancisco-pm
mailing list