perl with DBI, DBD, oracle, crontab problem

i'm on SUNOS SunOS sparc 5.10
install perl 5.8.4, DBI to work with Oracle database.
my perl script works fine when i log into my server and type a command:
but when i put it into crontab, it fails with message:

install_driver(Oracle) failed: Can't load '/usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBD/Oracle/' for module DBD::Oracle: perl: fatal: /u01/app/oracle/product/10.2.0/db_1/lib/ wrong ELF class: ELFCLASS64 at /usr/perl5/5.8.4/lib/sun4-solaris-64int/ line 230.
 at (eval 16) line 3
Compilation failed in require at (eval 16) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at /export/home/inuser/k1c/ line 96

in which line 96 in is:
my $dbh=DBI->connect('dbi:Oracle:orcl','user','password', {AutoCommit =>0});

what's wrong with DBI or crontab?
P/S: i will increase my points periodically
Who is Participating?
mrjoltcolaConnect With a Mentor Commented:
This usually happens when you are mismatching 32-bit and 64-bit programs / libraries.

Try typing this to verify that you may have mismatch.

file /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBD/Oracle/
file /u01/app/oracle/product/10.2.0/db_1/lib/

They both need to either be ELF 32-bit or ELF 64-bit, but not mixed.

If the Perl lib is 64-bit, then the question is are you running 64-bit Oracle? By default, 64-bit Oracle's lib is 64-bit, and so your code should work, but if vice-versa (Perl 32-bit, Oracle 64-bit, you need to set LD_LIBRARY_PATH to use $ORACLE_HOME/lib32).
Hi nanoterabeta,

crontab scripts run without a .profile (or similar).  Hence your environment is probably not set correctly when it runs under cron.  I think the problem, in this case, is the missing LD_LIBRARY_PATH environment variable - but there may be others.

nanoterabetaAuthor Commented:
that's awesome,
in my situation, Perl 32-bit and Oracle 64-bit, in command line mode, i can use SET command to see this:
so my script can work in command line
but how can i set this variable in crontab mode? what should i add to my script or something?
nanoterabetaAuthor Commented:
ok, that works
i create
put the following into it:

and it works fine in crontab mode
many thanks to mrjoltcola
sorry i have few points left
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.