seawarrior has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Environment variable woes connecting to Oracle
by stevieb (Canon) on Apr 11, 2017 at 18:39 UTC | |
by afoken (Chancellor) on Apr 12, 2017 at 13:51 UTC | |
by stevieb (Canon) on Apr 12, 2017 at 17:33 UTC | |
by afoken (Chancellor) on Apr 13, 2017 at 04:06 UTC | |
by seawarrior (Initiate) on Apr 11, 2017 at 18:59 UTC |