Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Environmental Variables and DBD::Oracle

by dhj (Novice)
on Sep 24, 2006 at 00:06 UTC ( [id://574559]=perlquestion: print w/replies, xml ) Need Help??

dhj has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I've got a script that makes a call to an oracle database. It just attempts to open a handle...thats it:
---- #!/usr/perl5/5.8.4/bin/perl -w use DBI; $host = "bo.boo.com"; $sid = "AAAA"; $user = 'secret'; $passwd = 'evenmoresecret'; $dbh = DBI->connect("dbi:Oracle:host=$host;sid=$sid", $user, $passwd); $dbh->disconnect; ---
Now if I run the script in shell where I have LD_LIBRARY_PATH environment variable defined it works just peachy. However if I don't first define LD_LIBRARY_PATH in the shell I get the following error:
--- install_driver(Oracle) failed: Can't load '/usr/perl5/site_perl/5.8.4/ +sun4-solaris-64int/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: + ld.so.1: perl: fatal: libclntsh.so.10.1: open failed: No such file o +r directory at /usr/perl5/5.8.4/lib/sun4-solaris-64int/DynaLoader.pm +line 230. 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 ./test2.pl line 12 --
I've tried inserting:
-- BEGIN { $ENV{'LD_LIBRARY_PATH'}='/local/src/local.perl/oracle/instantclient_10 +_2'; } --
at the beginning of by script but the result is the same error as I see if I have an undefined LD_LIBRARY_PATH. Any suggestions as to what I'm missing here?

Replies are listed 'Best First'.
Re: Environmental Variables and DBD::Oracle
by Tanktalus (Canon) on Sep 24, 2006 at 00:55 UTC

    Super Searching for LD_LIBRARY_PATH uncovers much help, including this node which, in turn, has a response pointing to this old node.

    Translation: try searching - you probably would have had your answer before now ;-)

      Tnx much. SuperSearch will now be the first thing I do ;')

      I actually had success doing something similar in that I called the perl script from a bash script were I set LD_LIBRARY_PATH. It worked but I wasn't happy about it.

      Tnx again.

      A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Environmental Variables and DBD::Oracle
by grep (Monsignor) on Sep 24, 2006 at 00:20 UTC
    If your system is setup correctly you should just have to run ldconfig as root. That should do it.


    grep
    Mynd you, mønk bites Kan be pretti nasti...

      As its a sun box I don't think ldconfig is available though I could use crle to do the same thing you suggest.

      Unfortunately I'm not in a position where I could could fiddle with the dynamic linker on this box. If I add '/local/src/local.perl/oracle/instantclient_10_2' to the default library path I'm running the risk of adversely affecting the horde of developers on the box.

      I'd really like to figure out why setting the LD_LIBRARY_PATH in my script isn't working. I stuck a print statement in the code and LD_LIBRARY_PATH is defined during run time. I put it in a BEGIN block at the start of the script before doing a 'use DBI' so LD_LIBRARY_PATH should exist at the right time. But obviously its not....:'(

Re: Environmental Variables and DBD::Oracle
by Joost (Canon) on Sep 24, 2006 at 00:14 UTC
Re: Environmental Variables and DBD::Oracle
by tobeya (Initiate) on Sep 25, 2006 at 17:26 UTC
    export ORACLE_HOME=/local/src/local.perl/oracle/instantclient_10 export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    Sometimes it needs to be /lib32 or /lib64 depending on how Oracle is installed, but then again that probably doesn't apply to the instant client. I haven't tried this for Oracle yet, but for Sybase, I added a block to Sybase.pm and forced it to get it right without user environment variables.
    { package DBD::Sybase; local $ENV{SYBASE}; $ENV{SYBASE} = "/syb/sybase00/rel12.5"; use DBI (); use DynaLoader (); use Exporter (); ... } 1;
    There is really no downside to hard-coding the environment variables if you don't plan to move the client directory around. If you upgrade it, DBD::Oracle has to be relinked anyways.
Re: Environmental Variables and DBD::Oracle
by lorn (Monk) on Sep 25, 2006 at 13:39 UTC

    Hi, monk!

    I have this problem too, i add the /home/lorn/oracle/product/10.2.0/client_1/ and /home/lorn/oracle/product/10.2.0/client_1/ to ld.so.conf

    echo "/home/lorn/oracle/product/10.2.0/client_1/" >> /etc/ld.so.conf echo "/home/lorn/oracle/product/10.2.0/client_1/lib" >> /etc/ld.so.con +f

    Now, run ldconfig

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://574559]
Approved by Joost
Front-paged by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (1)
As of 2024-04-24 14:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found