Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: Why must LD_LIBRARY_PATH be defined outside script for DBD::Oracle?

by holli (Abbot)
on Jul 26, 2019 at 06:59 UTC ( [id://11103417]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Why must LD_LIBRARY_PATH be defined outside script for DBD::Oracle?
in thread Why must LD_LIBRARY_PATH be defined outside script for DBD::Oracle?

Are you using Solaris? See DBI, DBD::Oracle and LD_LIBRARY_PATH.


holli

You can lead your users to water, but alas, you cannot drown them.

Replies are listed 'Best First'.
Re^5: Why must LD_LIBRARY_PATH be defined outside script for DBD::Oracle? DynaLoader solution
by bliako (Monsignor) on Jul 26, 2019 at 13:24 UTC
    ... $ENV{LD_LIBRARY_PATH} = "$ENV{ORACLE_HOME}/lib"; ... exec 'env',$0,@ARGV; # <<<< brrrrr!

    Notice that all this solution does is a) on startup, set the environment variable LD_LIBRARY_PATH to what you want (that's a mistake: it should have appended to it, not set=replace!) and b) re-spawn (=replace current process with new, which keeps same PID) perl script via exec which will take into consideration the new value of the environment variable (ideally) while c) guarding against re-spawning ad-infinitum by setting yet another environment variable/flag. Yikes!

    Using a shell script wrapper (contained in the question) does the same and in my opinion more cleanly.

    Here is my suggestion: tell DynaLoader where to additionally look for libraries after executing your perl script but before loading troublesome module. This is what the manual says on how this works:

    @dl_library_path should also be initialised with any other directories that can be determined from the environment at runtime (such as LD_LIBRARY_PATH for SunOS <<the OS Pericles used during the Pelloponisian War ;)>>).
    
    After initialisation @dl_library_path can be manipulated by an application using push and unshift before calling dl_findfile(). Unshift can be used to add directories to the front of the search order either to save search time or to override libraries with the same name in the 'normal' directories.
    
    The load function that dl_load_file() calls may require an absolute pathname. The dl_findfile() function and @dl_library_path can be used to search for and return the absolute pathname for the library/object that you wish to load.
    

    Notice the "that can be determined from the environment at runtime". That's why you need to re-spawn after modifying said enviroment variable. Anyway, I can't test it but pushing to @dl_library_path should do the trick. See Cleanly adding a directory to DynaLoader's search path? how to do that. For me, this is the cleanest solution.

    bw, bliako

Re^5: Why must LD_LIBRARY_PATH be defined outside script for DBD::Oracle?
by dsheroh (Monsignor) on Jul 26, 2019 at 07:41 UTC
    Are you using Solaris?
    /me looks at the original question:
    On Linux (currently testing RHEL6.5)...
    But the (currently) last post on that thread notes that this behavior is found in both Solaris and Linux, so it likely applies anyhow.
      Yes, thank you for pointing that out. I didn't realize RHEL is Red Hat. I mean I know that, but it's 10am and 31°C already. Thinking is a bit like walking through mollasses :)


      holli

      You can lead your users to water, but alas, you cannot drown them.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-03-28 16:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found