FAQ
Hi all,

Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?

If I set LD_LIBRARY_PATH from the command line, all is okay

[oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
Can't load
'/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file:
No such file or directory at
/usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
at -e line 1
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
[oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
[oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
1.15

But if I do the following instead in the Perl script, it does not work? How
to set the LD_LIBRARY_PATH then?

$ENV{ORACLE_HOME}=$ORACLE_HOME;
$ENV{ORACLE_SID}=$ORACLE_SID;
$ENV{PATH}="$ORACLE_HOME/bin:$PATH";
$ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";

FYI, the script is to run from a cron which is why am setting
LD_LIBRARY_PATH in the script.

Any response will be very much appreciated. Thanks in advance.

Search Discussions

  • Shlomi Fish at May 28, 2010 at 8:07 am

    On Friday 28 May 2010 10:45:14 newbie01 perl wrote:
    Hi all,

    Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?

    If I set LD_LIBRARY_PATH from the command line, all is okay

    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    Can't load
    '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi
    /auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.11.1:
    cannot open shared object file: No such file or directory at
    /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
    at -e line 1
    Compilation failed in require at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.
    [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    1.15

    But if I do the following instead in the Perl script, it does not work? How
    to set the LD_LIBRARY_PATH then?

    $ENV{ORACLE_HOME}=$ORACLE_HOME;
    $ENV{ORACLE_SID}=$ORACLE_SID;
    $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
    $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";

    FYI, the script is to run from a cron which is why am setting
    LD_LIBRARY_PATH in the script.
    If you're going to use "use DBD::Oracle;" in the script then you'll need to
    put these statements in a BEGIN block:

    [code]
    use vars qw($ORACLE_HOME $ORACLE_SID);

    BEGIN
    {
    $ORACLE_HOME = ...;
    $ORACLE_SID = ...;
    $ENV{ORACLE_HOME}=$ORACLE_HOME;
    $ENV{ORACLE_SID}=$ORACLE_SID;
    $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
    $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";
    }

    use DBD::Oracle;
    [/code]

    That's because "use" is executed at compile-time instead of run-time.

    Regards,

    Shlomi Fish

    --
    -----------------------------------------------------------------
    Shlomi Fish http://www.shlomifish.org/
    "The Human Hacking Field Guide" - http://shlom.in/hhfg

    God considered inflicting XSLT as the tenth plague of Egypt, but then
    decided against it because he thought it would be too evil.

    Please reply to list if it's a mailing list post - http://shlom.in/reply .
  • Martin Gainty at May 28, 2010 at 1:45 pm
    A workaround for LD_LIBRARY_PATH for me is to locate my Java jvm.dll in $JRE_BIN/bin/server and the resource dlls are in $JRE_HOME/bin
    the other libraries are on $PATH


    Martin Gainty



    Nimziki:Rabbi i'm not jewish..

    Rabbi Levison: ..Nobody's Perfect..



    (excerpt from movie "Independence Day")
    ______________________________________________
    Note de déni et de confidentialité

    Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




    From: shlomif@iglu.org.il
    To: beginners@perl.org
    Subject: Re: How to set LD_LIBRARY_PATH
    Date: Fri, 28 May 2010 11:06:41 +0300
    CC: newbie01.perl@gmail.com; dbi-users@perl.org
    On Friday 28 May 2010 10:45:14 newbie01 perl wrote:
    Hi all,

    Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?

    If I set LD_LIBRARY_PATH from the command line, all is okay

    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    Can't load
    '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi
    /auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.11.1:
    cannot open shared object file: No such file or directory at
    /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
    at -e line 1
    Compilation failed in require at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.
    [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    1.15

    But if I do the following instead in the Perl script, it does not work? How
    to set the LD_LIBRARY_PATH then?

    $ENV{ORACLE_HOME}=$ORACLE_HOME;
    $ENV{ORACLE_SID}=$ORACLE_SID;
    $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
    $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";

    FYI, the script is to run from a cron which is why am setting
    LD_LIBRARY_PATH in the script.
    If you're going to use "use DBD::Oracle;" in the script then you'll need to
    put these statements in a BEGIN block:

    [code]
    use vars qw($ORACLE_HOME $ORACLE_SID);

    BEGIN
    {
    $ORACLE_HOME = ...;
    $ORACLE_SID = ...;
    $ENV{ORACLE_HOME}=$ORACLE_HOME;
    $ENV{ORACLE_SID}=$ORACLE_SID;
    $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
    $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";
    }

    use DBD::Oracle;
    [/code]

    That's because "use" is executed at compile-time instead of run-time.

    Regards,

    Shlomi Fish

    --
    -----------------------------------------------------------------
    Shlomi Fish http://www.shlomifish.org/
    "The Human Hacking Field Guide" - http://shlom.in/hhfg

    God considered inflicting XSLT as the tenth plague of Egypt, but then
    decided against it because he thought it would be too evil.

    Please reply to list if it's a mailing list post - http://shlom.in/reply .
    _________________________________________________________________
    The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail.
    http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
  • John Scoles at May 28, 2010 at 10:14 am
    You will have to set those values before your modules load.

    So you should stick them in the BEGIN and that should work

    http://www.compuspec.net/reference/language/perl/BEGIN_and_END.shtml

    cheers
    John Scoles
    On Fri, May 28, 2010 at 3:45 AM, newbie01 perl wrote:

    Hi all,

    Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?

    If I set LD_LIBRARY_PATH from the command line, all is okay

    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    Can't load

    '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
    for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file:
    No such file or directory at
    /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
    at -e line 1
    Compilation failed in require at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.
    [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    1.15

    But if I do the following instead in the Perl script, it does not work? How
    to set the LD_LIBRARY_PATH then?

    $ENV{ORACLE_HOME}=$ORACLE_HOME;
    $ENV{ORACLE_SID}=$ORACLE_SID;
    $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
    $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";

    FYI, the script is to run from a cron which is why am setting
    LD_LIBRARY_PATH in the script.

    Any response will be very much appreciated. Thanks in advance.
    --
    Catch Alex & Sheeri at ODTUG/Kaleidoscope - June 27 - July 1.
    Hear Sheeri speak or email events@pythian.com to meet with Pythian.
  • Paul Johnson at May 28, 2010 at 4:33 pm

    On Fri, May 28, 2010 at 06:14:38AM -0400, John Scoles wrote:

    You will have to set those values before your modules load.

    So you should stick them in the BEGIN and that should work
    ... except where it doesn't, such as on Solaris for example. Here,
    LD_LIBRARY_PATH (at least) really does need to be set before the process
    starts. You can do this by writing a shell wrapper, or re-execing your
    perl script if the value is not already set.

    You're using linux and I'm not sure if this sort of messing about is
    required there.

    http://www.compuspec.net/reference/language/perl/BEGIN_and_END.shtml

    cheers
    John Scoles
    On Fri, May 28, 2010 at 3:45 AM, newbie01 perl wrote:

    Hi all,

    Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?

    If I set LD_LIBRARY_PATH from the command line, all is okay

    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    Can't load

    '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
    for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file:
    No such file or directory at
    /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
    at -e line 1
    Compilation failed in require at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.
    [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    1.15

    But if I do the following instead in the Perl script, it does not work? How
    to set the LD_LIBRARY_PATH then?

    $ENV{ORACLE_HOME}=$ORACLE_HOME;
    $ENV{ORACLE_SID}=$ORACLE_SID;
    $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
    $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";

    FYI, the script is to run from a cron which is why am setting
    LD_LIBRARY_PATH in the script.

    Any response will be very much appreciated. Thanks in advance.
    --
    Catch Alex & Sheeri at ODTUG/Kaleidoscope - June 27 - July 1.
    Hear Sheeri speak or email events@pythian.com to meet with Pythian.
    --
    Paul Johnson - paul@pjcj.net
    http://www.pjcj.net
  • Marilyn Sander at May 28, 2010 at 6:23 pm

    On May 28, 2010, at 9:33 AM, Paul Johnson wrote:
    On Fri, May 28, 2010 at 06:14:38AM -0400, John Scoles wrote:

    You will have to set those values before your modules load.

    So you should stick them in the BEGIN and that should work
    ... except where it doesn't, such as on Solaris for example. Here,
    LD_LIBRARY_PATH (at least) really does need to be set before the process
    starts. You can do this by writing a shell wrapper, or re-execing your
    perl script if the value is not already set.

    You're using linux and I'm not sure if this sort of messing about is
    required there.

    http://www.compuspec.net/reference/language/perl/BEGIN_and_END.shtml

    cheers
    John Scoles
    On Fri, May 28, 2010 at 3:45 AM, newbie01 perl wrote:

    Hi all,

    Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?

    If I set LD_LIBRARY_PATH from the command line, all is okay

    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    Can't load

    '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
    for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file:
    No such file or directory at
    /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
    at -e line 1
    Compilation failed in require at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.
    [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    1.15

    But if I do the following instead in the Perl script, it does not work? How
    to set the LD_LIBRARY_PATH then?

    $ENV{ORACLE_HOME}=$ORACLE_HOME;
    $ENV{ORACLE_SID}=$ORACLE_SID;
    $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
    $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";

    FYI, the script is to run from a cron which is why am setting
    LD_LIBRARY_PATH in the script.

    Any response will be very much appreciated. Thanks in advance.
    Have you considered doing a require instead of a use. With require, the loading is done at run time, and would be governed by the setting of LD_LIBRARY_PATH, at the time the require statement is executed. Just set LD_LIBRARY_PATH before doing the require.
    --Marilyn
  • Paul Johnson at May 29, 2010 at 1:24 pm

    On Fri, May 28, 2010 at 11:23:32AM -0700, Marilyn Sander wrote:
    On May 28, 2010, at 9:33 AM, Paul Johnson wrote:
    On Fri, May 28, 2010 at 06:14:38AM -0400, John Scoles wrote:

    You will have to set those values before your modules load.

    So you should stick them in the BEGIN and that should work
    ... except where it doesn't, such as on Solaris for example. Here,
    LD_LIBRARY_PATH (at least) really does need to be set before the process
    starts. You can do this by writing a shell wrapper, or re-execing your
    perl script if the value is not already set.
    Have you considered doing a require instead of a use. With require, the
    loading is done at run time, and would be governed by the setting of
    LD_LIBRARY_PATH, at the time the require statement is executed. Just set
    LD_LIBRARY_PATH before doing the require.
    I'm afraid that you may have misunderstood what I wrote. There are
    times when you really do need to set the variable before the process
    starts.

    --
    Paul Johnson - paul@pjcj.net
    http://www.pjcj.net
  • Marilyn Sander at May 30, 2010 at 5:47 pm

    On May 29, 2010, at 6:24 AM, Paul Johnson wrote:
    On Fri, May 28, 2010 at 11:23:32AM -0700, Marilyn Sander wrote:
    On May 28, 2010, at 9:33 AM, Paul Johnson wrote:
    On Fri, May 28, 2010 at 06:14:38AM -0400, John Scoles wrote:

    You will have to set those values before your modules load.

    So you should stick them in the BEGIN and that should work
    ... except where it doesn't, such as on Solaris for example. Here,
    LD_LIBRARY_PATH (at least) really does need to be set before the
    process
    starts. You can do this by writing a shell wrapper, or re-execing
    your
    perl script if the value is not already set.
    Have you considered doing a require instead of a use. With
    require, the
    loading is done at run time, and would be governed by the setting of
    LD_LIBRARY_PATH, at the time the require statement is executed.
    Just set
    LD_LIBRARY_PATH before doing the require.
    I'm afraid that you may have misunderstood what I wrote. There are
    times when you really do need to set the variable before the process
    starts.
    I did not misunderstand what you wrote. My reasoning was that the
    thing being
    loaded is a shared object (.so file). The system loader (ld) has to
    be invoked for loading
    a shared object. That seems to me to require a separate process, with
    an environment
    stack inherited from the Perl process that invokes it. I was also
    assuming that setting
    an environment variable at run time would set the environment for the
    Perl process
    that is executing the Perl program. However, I did not test it. I
    will test it and see what happens.
    --Marilyn
  • Jonathan Leffler at May 31, 2010 at 2:54 pm

    On Sun, May 30, 2010 at 10:47 AM, Marilyn Sander wrote:
    [...] My reasoning was that the thing being
    loaded is a shared object (.so file). The system loader (ld) has to be
    invoked for loading
    a shared object. That seems to me to require a separate process, with an
    environment
    stack inherited from the Perl process that invokes it.

    There's a problem here. What you describe is not what happens.

    The system loader, ld, is used to create executables and shared objects. It
    indeed is a separate program that is most often invoked automatically by a
    compiler - GCC for example.

    There is a wholly separate module, often with a name such as ld.so.1, which
    is the dynamic library loader. It is actually a part of the program you are
    running - Perl in the current context. It is responsible for loading other
    shared libraries into the current process. Dynamically loading a shared
    library adds the code to the current process; it does not invoke a separate
    program/process.


    --
    Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h>
    Guardian of DBD::Informix - v2008.0513 - http://dbi.perl.org
    "Blessed are we who can laugh at ourselves, for we shall never cease to be
    amused."
  • Bobak, Mark at May 29, 2010 at 4:21 pm
    I'd argue you want to use a shell wrapper anyhow, because rather than setting those variables explicitly, you ought to do something like:
    export ORACLE_SID=your_sid
    export ORAENV_ASK=NO
    . oraenv

    and Oracle will set it all for you, and if/when something changes or is upgraded, your code will continue to do the right thing.

    -Mark
    ________________________________________
    From: Paul Johnson [paul@pjcj.net]
    Sent: Friday, May 28, 2010 12:33
    To: John Scoles
    Cc: newbie01 perl; beginners; dbi-users
    Subject: Re: How to set LD_LIBRARY_PATH
    On Fri, May 28, 2010 at 06:14:38AM -0400, John Scoles wrote:

    You will have to set those values before your modules load.

    So you should stick them in the BEGIN and that should work
    ... except where it doesn't, such as on Solaris for example. Here,
    LD_LIBRARY_PATH (at least) really does need to be set before the process
    starts. You can do this by writing a shell wrapper, or re-execing your
    perl script if the value is not already set.

    You're using linux and I'm not sure if this sort of messing about is
    required there.

    http://www.compuspec.net/reference/language/perl/BEGIN_and_END.shtml

    cheers
    John Scoles
    On Fri, May 28, 2010 at 3:45 AM, newbie01 perl wrote:

    Hi all,

    Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?

    If I set LD_LIBRARY_PATH from the command line, all is okay

    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    Can't load

    '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
    for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file:
    No such file or directory at
    /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
    at -e line 1
    Compilation failed in require at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.
    [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    1.15

    But if I do the following instead in the Perl script, it does not work? How
    to set the LD_LIBRARY_PATH then?

    $ENV{ORACLE_HOME}=$ORACLE_HOME;
    $ENV{ORACLE_SID}=$ORACLE_SID;
    $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
    $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";

    FYI, the script is to run from a cron which is why am setting
    LD_LIBRARY_PATH in the script.

    Any response will be very much appreciated. Thanks in advance.
    --
    Catch Alex & Sheeri at ODTUG/Kaleidoscope - June 27 - July 1.
    Hear Sheeri speak or email events@pythian.com to meet with Pythian.
    --
    Paul Johnson - paul@pjcj.net
    http://www.pjcj.net
  • Chas. Owens at May 30, 2010 at 12:44 pm

    On Sat, May 29, 2010 at 12:19, Bobak, Mark wrote:
    I'd argue you want to use a shell wrapper anyhow, because rather than setting those variables explicitly, you ought to do something like:
    export ORACLE_SID=your_sid
    export ORAENV_ASK=NO
    . oraenv

    and Oracle will set it all for you, and if/when something changes or is upgraded, your code will continue to do the right thing.
    snip

    Yeah, using a wrapper shell script to setup the environment is always
    a good idea. I have seen too many Perl scripts (and C programs) fail
    miserably when run by cron because they assumed some environment would
    be present. This would also be a good place to set PERL5LIB and any
    other variables you need to exist.

    --
    Chas. Owens
    wonkden.net
    The most important skill a programmer can have is the ability to read.
  • Jonathan Leffler at May 28, 2010 at 3:32 pm
    The dynamic loader read LD_LIBRARY_PATH when (before?) Perl gets going. AFAIK, it doesn't reread it, so changing it in Perl code is too late unless you set it and exec your code again (which is basically saying it is too late).

    I'm tolerably certain this applies to Solaris; I think it applies elsewhere too.

    JL


    Sent from my BlackBerry® smartphone, powered by CREDO Mobile.

    -----Original Message-----
    From: newbie01 perl <newbie01.perl@gmail.com>
    Date: Fri, 28 May 2010 19:45:14
    To: beginners<beginners@perl.org>; dbi-users<dbi-users@perl.org>
    Subject: How to set LD_LIBRARY_PATH

    Hi all,

    Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?

    If I set LD_LIBRARY_PATH from the command line, all is okay

    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    Can't load
    '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
    for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file:
    No such file or directory at
    /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
    at -e line 1
    Compilation failed in require at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.
    [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    1.15

    But if I do the following instead in the Perl script, it does not work? How
    to set the LD_LIBRARY_PATH then?

    $ENV{ORACLE_HOME}=$ORACLE_HOME;
    $ENV{ORACLE_SID}=$ORACLE_SID;
    $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
    $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";

    FYI, the script is to run from a cron which is why am setting
    LD_LIBRARY_PATH in the script.

    Any response will be very much appreciated. Thanks in advance.
  • Oscar Gomez at May 28, 2010 at 10:26 pm
    create shell script, first set enviroment variables Oracle then
    execute script perl

    jonathan.leffler@gmail.com escribió:
    The dynamic loader read LD_LIBRARY_PATH when (before?) Perl gets going. AFAIK, it doesn't reread it, so changing it in Perl code is too late unless you set it and exec your code again (which is basically saying it is too late).

    I'm tolerably certain this applies to Solaris; I think it applies elsewhere too.

    JL


    Sent from my BlackBerry® smartphone, powered by CREDO Mobile.

    -----Original Message-----
    From: newbie01 perl <newbie01.perl@gmail.com>
    Date: Fri, 28 May 2010 19:45:14
    To: beginners<beginners@perl.org>; dbi-users<dbi-users@perl.org>
    Subject: How to set LD_LIBRARY_PATH

    Hi all,

    Can someone advise how to set LD_LIBRARY_PATH from within the Perl scripts?

    If I set LD_LIBRARY_PATH from the command line, all is okay

    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    Can't load
    '/oracle/product/db/11.1/perl/lib/site_perl/5.8.3/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
    for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file:
    No such file or directory at
    /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/DynaLoader.pm line 230.
    at -e line 1
    Compilation failed in require at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.
    [oracle ~]$ export LD_LIBRARY_PATH=/oracle/product/db/11.1/lib
    [oracle ~]$ perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'
    1.15

    But if I do the following instead in the Perl script, it does not work? How
    to set the LD_LIBRARY_PATH then?

    $ENV{ORACLE_HOME}=$ORACLE_HOME;
    $ENV{ORACLE_SID}=$ORACLE_SID;
    $ENV{PATH}="$ORACLE_HOME/bin:$PATH";
    $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib";

    FYI, the script is to run from a cron which is why am setting
    LD_LIBRARY_PATH in the script.

    Any response will be very much appreciated. Thanks in advance.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedMay 28, '10 at 7:45a
activeMay 31, '10 at 2:54p
posts13
users10
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase