perl + oracle environment

From: Stephens, Chris <>
Date: Tue, 27 Jan 2009 13:36:03 -0600
Message-ID: <> on linux  

I'm struggling to get a perl script up and running on cron. It absolutely has something to do with the environment under which it is running but I can't figure out what the solution is.  

The scipt is called through a soft link. I get the Oracle Sid from the link name and proceed to set the environment from there. I can't seem to figure out how to run oraenv from perl so right now I am doing the following:  

#Set Oracle Home

if (! open ORATAB, "/etc/oratab") {

  die "/etc/oratab does not exist. unable to determine ORACLE_HOME";


while (<ORATAB>) {

  next unless $_ =~ /^$database:(.*):/;


$ENV{LD_LIBRARY_PATH} = "$ENV{'ORACLE_HOME'}/lib:/usr/lib:/usr/lib64";

$ENV{TNS_ADMIN} = "$ENV{'ORACLE_HOME'}/network/admin";


my $dbh = DBI->connect("dbi:Oracle:host=$host;sid=$database", $db_user, $db_pass)

         || die "Unable to connect to $database \n" . DBI->errstr;  

# get the directory where datapump will write to.

my $sth = $dbh->prepare('select directory_path from dba_directories where directory_name = ?')

        or die "Couldn't prepare statement" . $dbh->errstr;  


        or die "Couldn't execute statement" . $sth->errstr;  

my $dp_os_dir = $sth->fetchrow_array();    

The error I'm getting is:  

[oracle_at_dataserver2 scripts]$ ./dp_remgt_full

install_driver(Oracle) failed: Can't load '/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Ora cle/' for module DBD::Oracle: cannot open shared object file: No such file or directory at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/ line 230, <ORATAB> line 26.

 at (eval 11) line 3

Compilation failed in require at (eval 11) line 3, <ORATAB> line 26.

Perhaps a required shared library or dll isn't installed where expected

 at ./dp_remgt_full line 52  

After I run . oraenv manually, everything is fine.  

Does anyone know what my problem is? I would rather not put a shell wrapper around it to call oraenv with ORAENV_ASK=NO. ...though I would love to do that from within the perl script if I could figure out how (I made several attempts at this with no luck).    

        This message is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by email reply.

Received on Tue Jan 27 2009 - 13:36:03 CST

Original text of this message