perl library error when running from cron

perl library error when running from cron

I have a perl script that uses a DBD (DataBase Driver) in a local directory. It works fine running it from the command line, but when run from cron there is no output. Arg! I grabbed the STDERR and, sure enough, it.s choking on the oracle module.

The error:
install_driver(Oracle) failed: Can't load '/opt/app/foo/lib/perl5/site_perl/5.8.7/sun4-solaris-thread-multi-64/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: ld.so.1: perl: fatal: libnnz10.so: open failed: No such file or directory at /usr/local/lib/perl5/5.8.7/sun4-solaris-thread-multi-64/DynaLoader.pm line 230. at (eval 3) line 3

Looking up the line in DynaLoader.pm yielded this message. Apparently the error was common enough that the module was commented for it.

# Many dynamic extension loading problems will appear to come from
# this section of code: XYZ failed at line 123 of DynaLoader.pm.
# Often these errors are actually occurring in the initialisation
# C code of the extension XS file. Perl reports the error as being
# in this perl code simply because this was the last perl code
# it executed.

I found several articles that recommended adding the module in question to the LD_LIBRARY_PATH, but that didn.t work. I included the oracle lib path and some other system lib paths, still no. I needed three things:

ORACLE_HOME must be set
LD_LIBRARY_PATH needs the perl oracle DBD path.
LD_LIBRARY_PATH needs the oracle home lib path.

That ORACLE_HOME bit took me forever to figure out. I ended up dumping most of the .profile into a shell wrapper and eliminating pieces till I found the 3 things that were required for it to work

For plain sh, adding these lines to a wrapper script worked. I probably could have added the equivalent directly to perl, but the shell script was already doing other things so I might as well use it.

ORACLE_HOME=/opt/app/doam_nas01/ORACLE10/10.2.0
export ORACLE_HOME

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/opt/app/foo/lib/perl5/site_perl/5.8.7/sun4-solaris-thread-multi-64/auto/DBD/Oracle
export LD_LIBRARY_PATH

These notes were scribled down December, 2007 by Roy Corey

Feel free to email me any questions, suggestions, corrections, etc.