views:

45

answers:

2

Hi I am using DBD::Oracle in my script to query into oracle database. When I am running this script its working fine but when i schedule to run this from cron its giving below error

install_driver(Oracle) failed: Can't load '/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libnnz10.so: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.5/i386-linux-thread-multi/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 expected
 at /scripts/db/dbquery.pl line 50

Line 50 is:

my $dbh = DBI->connect("dbi:Oracle:$tns","$dbuser","$dbpass");

Please suggest, how to fix this.

A: 

Looks like you may need to install Oracle client libraries in order for this to work. libnnz10.so, which needs to be dynamically loaded by the module, is apparently part of the install.

Of note is that Oracle is proprietary and not GPL-compliant, therefore almost no Linux distro will make it available through their repository. This means you are probably going to have to install it yourself.

Edit: Make sure LD_CONFIG_PATH points to the directory where the library resides.

Alternately, you could just append a line to /etc/ld.so.conf with the path to the Oracle client libraries.

amphetamachine
If it's working from the command line but failing from cron, the library must already be installed, but maybe some environment variable is needed to make it look in the right place.
ysth
@ysth: Yes the lib are already installed. Can you help to set env variable please.
Space
Space, you first have to figure out which variables Oracle needs, read the documentation, and compare the output of `/usr/bin/env` in your shell and when run from cron.
daxim
+1  A: 

Does sound like the required Oracle environment variables have not been set for cron (re: ysth comment to amphetamachine answer).

Have a look at this answer to SO question: How can I use a database server from a Perl CGI script? for some guidance.

To help, see what Oracle ENV variables you have set in your login profile:

env | grep -i oracle

Pretty much all what you see here should be set as $ENV{} variables in your Perl script or depending on version of cron you are running it could also be added to your crontab file:

ORACLE_HOME=/home/oracle/product/10.x.x
* * * * * /path/to/your/script.pl

/I3az/

draegtun
+1 the `cron` execution environment is *quite* impoverished, which is a surprise to people accustomed to the fully-loaded environ of an interactive session.
pilcrow