--- Praveen Ray <[EMAIL PROTECTED]> wrote:
> --- Perrin Harkins <[EMAIL PROTECTED]> wrote:
>
> > On Tue, 2005-09-06 at 06:23 -0700, Thomas Hilbig
> wrote:
> > > I am struggling with a (simple?) DBI problem
> under MP2
> > > on Fedora Core 3. A script that uses Oracle-DBI
> works
> > > under regular CGI but fails under MP2 with the
> > > following error:
> > >
> > > ERROR OCIEnvNlsCreate (check ORACLE_HOME and
> NLS
> > > settings etc.)
> >
> > This has always turned out to be either not
> exporting
> > environment
> > variables correctly or permissions problems for
> me.
> > Double-check your
> > permissions by trying to read the required Oracle
> files
> > as user
> > "nobody." If you post your config file, someone
> may be
> > able to spot the
> > problem.
> >
>
> You can try something like :
>
> PerlSetVar ORACLE_HOME /home/oracle/oracle10g
>
> or something similar instead of relying upon
> ORACLE_HOME
> getting exported from the startup shell.
>
> - Praveen
>
It does not appear to be a permissions problem (I've
run the httpd as User oracle), but turning on DBI
tracing the problem does look like an environment
variable problem. The ORACLE_HOME and other
environment variables are not getting passed to DBI
under mod_perl.
As you can see, in httpd.conf and the cgi script
itself I am trying everything to set the ORACLE_HOME
environment variables. However, in the dbitrace.log
file, it appears nothing has worked. The same script
works under a normal CGI (no mp2) and the dbitrace.log
file shows a healthy set of environment variables.
This looks so simple; why aren't my environment
variables kept under mp2?
Thanks, Tom
httpd.conf (snip)=======================
LoadModule perl_module modules/mod_perl.so
SetEnv "NLS_LANG" "AMERICAN_AMERICA.UTF8"
PerlSetEnv "NLS_LANG" "AMERICAN_AMERICA.UTF8"
SetEnv ORACLE_HOME
"/home/oracle/product/10.2.0/db_1"
PerlSetEnv ORACLE_HOME
"/home/oracle/product/10.2.0/db_1"
SetEnv LD_LIBRARY_PATH
/home/oracle/product/10.2.0/db_1/lib
PerlSetEnv LD_LIBRARY_PATH
/home/oracle/product/10.2.0/db_1/lib
SetEnv ORACLE_SID tomdb1
PerlSetEnv ORACLE_SID tomdb1
ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
<Directory "/usr/local/apache2/cgi-bin">
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
tomdb1test.pl (CGI script) =====================
#!/usr/bin/perl
use DBI ;
use strict ;
my ($dbh) ;
$|=1 ;
# This is a CGI script. Debugging problem with modperl
$ENV{ORACLE_HOME}='/home/oracle/product/10.2.0/db_1';
$ENV{'ORACLE_SID'}="tomdb1";
$ENV{'LD_LIBRARY_PATH'}="/home/oracle/product/10.2.0/db_1/lib";
$ENV{'LD_ASSUME_KERNEL'} = "2.4.1" ;
$ENV{'LD_PRELOAD'} =
"/usr/lib/libInternalSymbols.so" ;
$ENV{'NLS_LANG'}= "AMERICAN_AMERICA.UTF8" ;
$ENV{'TNS_ADMIN'}= "/home/oracle" ;
# unlink '/tmp/dbitrace.log' if -e
'/tmp/dbitrace.log' ;
DBI->trace( 16, '/tmp/dbitrace.log' ) ;
print "Content-type: text/plain\n\n";
# Print out the Environment and @INC
my $lineCount = 1 ;
foreach my $var (sort(keys(%ENV))) {
my $val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "[$lineCount] ${var}=\"${val}\"\n";
$lineCount++ ;
}
print "[EMAIL PROTECTED] = ", join("\n ", @INC), "\n" ;
# Log into Oracle
eval {
$dbh =
DBI->connect("dbi:Oracle:host=redhat;sid=tomdb1;port=1521",
'scott', 'tiger') || die "Database Connect Failed: $@
\n $DBI::errstr\n";
} ;
if($@) {
print "Connection to Oracle Failed: $@ \n";
} else {
print "Connection to Oracle Successful\n" ;
$dbh->disconnect;
}
dbitrace.log ==================================
Environment variables:
LANG=C
TERM=xterm
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
PWD=/
SHLVL=1
_=/sbin/initlog
OCINlsEnvironmentVariableGet(1,0,93,0,2)=SUCCESS
OCINlsEnvironmentVariableGet(1,0,94,0,2)=SUCCESS
OCINlsEnvCreate(9361cd4,3,0,0,0,0,0,0,1,1)=ERROR
DESTROY for DBI::db=HASH(0x91ba654) ignored -
handle not initialised
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/