0

I am running a cgi script from an onclick event in html.

HTML

<button onclick="self.location='http:**link**/test.cgi?myfield=PRD7-QF_P7';">Click me</button>

test.cgi Script

use DBI;
use CGI::Carp qw(carpout fatalsToBrowser);
BEGIN
{
 $ENV{'ORACLE_HOME'}='/data/softs/oracle/10.2.0.3/';
 $ENV{'LD_LIBRARY_PATH'}='/data/softs/oracle/10.2.0.3/lib';
}

my $cgi = CGI->new;
#my $parameter = $cgi->param("myfield");
print "Content-type: text/html\n\n";
my $version = "2.1";
my $cgi = CGI->new;
my $parameter = $cgi->param("myfield");
print "Content-type: text/html\n\n";
print "This is a test perl script\n\n";
print "Parameter=${parameter}\n";
my $connection_details = DBstringToConnection($parameter);

my $AMDORA_TNS_FM = @$connection_details[0];
my $AMDORA_USER_FM = @$connection_details[1];
my $AMDORA_PASSWORD_FM = @$connection_details[2];
my $AMDORA_SCHEMA_FM = @$connection_details[3];
my $AMDORA_SERVICE_FM = @$connection_details[4];

my $dbhfm = DBI->connect("dbi:Oracle:$AMDORA_TNS_FM", $AMDORA_USER_FM,$AMDORA_PASSWORD_FM)
  or die DBI->errstr;

I am setting the Oracle_home and ld_library_path at the start of file. When i run the cgi script from unix terminal it's working fine. But when i run the script from the browser HTML file, it's giving this error:

install_driver(Oracle) failed: Can't locate DBD/Oracle.pm in @INC (@INC contains: /usr/lib/perl5/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/5.10.0 /usr/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/vendor_perl .) at (eval 9) line 3.

Perhaps the DBD::Oracle perl module hasn't been fully installed,
or perhaps the capitalisation of 'Oracle' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge, mysql.
 at /remote/users/sasahu/public_html/dashboard/test.cgi line 47

I think DBI->connect will use the DBD::Oracle package for Oracle connection, which works fine in unix terminal, but in the browser it gives the above error.

Could anybody please say how to resolve the problem. Thanks in Advance.

2
  • 2
    Compare that @INC with the one you get from perl -V in the shell? Commented Aug 3, 2015 at 9:01
  • 1
    Your @$connection_details[0] (and the following four lines) are far less confusingly written as $connection_details->[0]. Or perhaps combine them all as my ($AMDORA_TNS_FM, $AMDORA_USER_FM, $AMDORA_PASSWORD_FM, $AMDORA_SCHEMA_FM, $AMDORA_SERVICE_FM) = @$connection_details. Commented Aug 3, 2015 at 11:15

1 Answer 1

2

Looks like you have to set the environment Variable ORACLE_HOME also for the user which runs the apache webserver. And make it available in apache.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.