?
Solved

perl with DBI, DBD, oracle, crontab problem

Posted on 2009-04-09
4
Medium Priority
?
1,592 Views
Last Modified: 2013-12-27
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:
./my_script.pl
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/Oracle.so' for module DBD::Oracle: ld.so.1: perl: fatal: /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1: wrong ELF class: ELFCLASS64 at /usr/perl5/5.8.4/lib/sun4-solaris-64int/DynaLoader.pm 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/my_script.pl line 96


in which line 96 in my_script.pl 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
0
Comment
Question by:nanoterabeta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 25

Expert Comment

by:lwadwell
ID: 24106060
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.

lwadwell
0
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 140 total points
ID: 24108204
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/Oracle.so
file /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1

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).
0
 

Author Comment

by:nanoterabeta
ID: 24113190
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:
LD_LIBRARY_PATH=/u01/app/oracle/product/10.2.0/db_1/lib32
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?
0
 

Author Comment

by:nanoterabeta
ID: 24113336
ok, that works
i create my_script.sh
put the following into it:
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export ORACLE_HOME
LD_LIBRARY_PATH=/u01/app/oracle/product/10.2.0/db_1/lib32
export LD_LIBRARY_PATH
/export/home/inuser/k1c/my_script.pl

and it works fine in crontab mode
many thanks to mrjoltcola
sorry i have few points left
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses
Course of the Month12 days, 3 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question