简体   繁体   中英

Error while executing the perl script and not able to set the Environment Variables

I executed the below perl script,

#!/usr/bin/perl

use strict;
use DBD::Oracle;
use DBI;

my $driver = "Oracle";
my $database = "host=xxxxxx;port=6210;sid=xxxx";
my $dsn = "DBI:$driver:$database";
my $userid = "xxxxx";
my $password = "xxxxx";

#Database Connection
my $dbh = DBI->connect($dsn, $userid, $password,{RaiseError => 1}) or die "$DB::errstr";
my $sth = $dbh->prepare("update collabuser set user_email='aravikum.wipro.com' where user_login='aravikum'") or die "$DBI::errstr";

$sth->execute() or die "couldn't execute statementn$!";
$sth->rows;

#End of Program
$sth->finish();
$dbh->disconnect();

I got the error below:

Can't load '/usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libocci.so.11.1: cannot open shared object file: No such file or directory at /usr/lib64/perl5/DynaLoader.pm line 190.
 at perlupdt.pl line 11.
Compilation failed in require at perlupdt.pl line 11.
BEGIN failed--compilation aborted at perlupdt.pl line 11.

on googling, i got an answer like running the below export commands fixed the issue. so, i executed and it worked fine,

export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib:$LD_LIBRARY_PATH
export PATH=/usr/lib/oracle/11.2/client64/bin:$PATH

But, i cant execute the above commands each and every time when i login to putty,

I decided to put this export inside the script so added these at the starting of the script,

$ENV{"ORACLE_HOME"} = '/usr/lib/oracle/11.2/client64';
$ENV{"LD_LIBRARY_PATH"} = '/usr/lib/oracle/11.2/client64/lib:$LD_LIBRARY_PATH';
$ENV{"PATH"} = '/usr/lib/oracle/11.2/client64/bin:$PATH';

But I am getting the above stated error, please suggest a solution to import these commands inside my perl script.

在 etc/profile 和 etc/bashrc 中设置上述导出命令并在 etc/profile.d 下添加为 .sh 文件后修复了问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM