Given this test program that connects to Oracle:

#!/usr/bin/perl -I/home/install/perl $ENV{'ORACLE_HOME'}="/home/root/home/xyzco/oracle/oracle/product/12.1. +0/dbHome_1"; $ENV{'LD_LIBRARY_PATH'}="/home/root/home/xyzco/oracle/oracle/product/1 +2.1.0/dbHome_1/lib:/lib:/usr/lib"; use DBI; print $ENV{'LD_LIBRARY_PATH'}; $dbh = DBI->connect( "dbi:Oracle:host=127.0.0.1;sid=V1011679;port=1521 +", isx, devpassXD0kei4Eo3W3n9n, { AutoCommit => 1} );

The output is as follows; i.e. it fails to connect complaining that it can't load /home/install/perl/auto/DBD/Oracle/Oracle.so.

site1:/home/install/perl/auto/DBD/Oracle # perl test.pl AJS Dynaloader -/home/install/perl/auto/DBI/DBI.so- AJS Dynaloader AJS Dynaloader -/home/install/perl/auto/DBD/Oracle/Oracle.so- /home/root/home/xyzco/oracle/oracle/product/12.1.0/dbHome_1/lib:/lib:/ +usr/libAJS Dynaloader /home/root/home/xyzco/oracle/oracle/product/12. +1.0/dbHome_1/lib:/lib:/usr/lib install_driver(Oracle) failed: Can't load '/home/install/perl/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/lib/perl5/ +5.10.0/x86_64-linux-thread-multi/DynaLoader.pm line 205. at (eval 3) line 3 Compilation failed in require at (eval 3) line 3. Perhaps a required shared library or dll isn't installed where expecte +d at test.pl line 7

HOWEVER, if I explicitly define the environment variable in the shell:

site1:/home/install/perl/auto/DBD/Oracle # declare -x LD_LIBRARY_PATH= +"/home/root/home/xyzco/oracle/oracle/product/12.1.0/dbHome_1/lib:/lib +:/usr/lib"

and then run the program:

site1:/home/install/perl/auto/DBD/Oracle # perl test.pl AJS Dynaloader -/home/install/perl/auto/DBI/DBI.so- AJS Dynaloader /home/root/home/xyzco/oracle/oracle/product/12.1.0/dbHo +me_1/lib:/lib:/usr/lib AJS Dynaloader -/home/install/perl/auto/DBD/Oracle/Oracle.so- /home/root/home/xyzco/oracle/oracle/product/12.1.0/dbHome_1/lib:/lib:/ +usr/libAJS Dynaloader /home/root/home/xyzco/oracle/oracle/product/12. +1.0/dbHome_1/lib:/lib:/usr/lib

...then it is successful. Why doesn't the program work when I define the environment variable from inside the program but not in the shell? OS is SLES11. Thanks for your help!


In reply to Environment variable woes connecting to Oracle by seawarrior

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.