in reply to Re^3: Env Variables
in thread Env Variables

sure thing marto,
#!/usr/bin/perl use DBI; use CGI; #BEGIN{ $ENV{'ORACLE_HOME'}="/opt/oracle/product/10.2.0/client_1"; $ENV{'LD_LIBRARY_PATH'}="/opt/oracle/product/10.2.0/client_1/lib32:/us +r/local/lib/sprolib:/usr/local/lib:/usr/lib:/usr/openwin/lib:/usr/dt/ +lib:/usr/lib:/usr/ucblib"; #$ENV{'TWO_TASK'}='DB'; #} print "Content-Type:text/html\n\n"; print<<__HTML__; <html> <head> </head> <title>Test123</title> <body> __HTML__ my $DB="sampleSID"; my $HOST="DBSERVERNAME"; my $PORT="1521"; my $USER="ms_swan"; my $PASS="ms_swan915"; print "<br><br>"; print "Environment variables are:". %ENV; print %ENV; print "<br><br><br><br><br><br>"; print "This is before connecting\n"; my $MysqlDbh = DBI->connect("DBI:Oracle:host=$HOST;sid=$DB;por +t=$PORT",$USER, $PASS, {RaiseError => 0, AutoCommit => 1,PrintError = +> 1 }); print $MysqlDbh; if (! $MysqlDbh) { print "Error Error Error"; }else{ print "Connected"; } my $Statement="select * from AdditionalNodeInformation where Node = '1 +23'"; my $Sth = $MysqlDbh->prepare($Statement); if (! $Sth) { print "Unable to prepare query $Statement.\n$DBI::errstr\n"; exit; } if (! $Sth->execute) { print "Unable to execute query $Statement\n$DBI::errstr\n"; exit; }else{ print "This query has been executed"; } print "</html>";


You can see that the env vars are set.. As 'almut' said, its a problem with Dynamic linking libs.. But i am not certain abt where to set it, other than in crle.. Also, this is running on a TIP server, which is a variation of the IBM's Websphere server.. So, it can be an issue with the server too... And about the error,
install_driver(Oracle) failed: Can't load '/usr/local/lib/perl5/site_p +erl/5.8.8/sun4-solaris/auto/DBD/Oracle /Oracle.so' for module DBD::Or +acle: ld.so.1: perl: fatal: /opt/oracle/product/10.2.0/client_1/lib/l +ibclntsh.so.10.1: wrong ELF class: ELFCLASS64 at /usr/local/lib/perl5 +/5.8.8/sun4-solaris/DynaLoader.pm line 230. at (eval 4) line 3 Compilation failed in require Perhaps a required shared library or dll isn't installed where expecte +d
I read that Wrong ELFCLASS error occurs cause of 64-32 bit compatibility.. But this cant be the reason here, as the script works fine on COmmand line..

Regards,
Blub:)

Replies are listed 'Best First'.
Re^5: Env Variables
by marto (Cardinal) on Jun 10, 2010 at 17:28 UTC

    Well you have no use strict; use warnings; in this code, and you use CGI; but never actually use it (consider the latter have of my previous advice. Also a templating system such as HTML::Template may be worth looking into regarding separating your HTML from your perl code.

    On to Oracle matters. At work we use Solaris 10, perl 5.8.8 (I know, I'm working on it) and Oracle 10. IIRC I built DBD::Oracle and had no issues (I can check my exact steps tomorrow morning). We use DBD::Oracle a lot, and out main perl app is a CGI::Application. In the morning I'll post again with some specifics. Until then could you please post how you installed DBD::Oracle, perhaps a perl -V (note the upper case V) as well?

      Hi marto
      Thanks for all the help mate..
      I finally solved the issue..
      My webserver is started by a shell script, i just needed to include these Dynamic Library Files in that, that is, i just needed to export LD_LIBRARY_PATH inside the startup Script..
      Thanks for all the effort and concern
      Blub:)
      I am using Perl 5.8.8 also oracle client 10 .. Also, i had no issues while building the DBD for Oracle.. I had to export the ORACLE_HOME and LD_LIBRARY_PATH then i did a perl Makefile.PL , make , make test, make install.. It all worked fine..
Re^5: Env Variables
by proceng (Scribe) on Jun 10, 2010 at 19:07 UTC
    #BEGIN{ $ENV{'ORACLE_HOME'}="/opt/oracle/product/10.2.0/client_1"; $ENV{'LD_LIBRARY_PATH'}="/opt/oracle/product/10.2.0/client_1/lib32:/us +r/local/lib/sprolib:/usr/local/lib:/usr/lib:/usr/openwin/lib:/usr/dt/ +lib:/usr/lib:/usr/ucblib";
    shows /opt/oracle/product/10.2.0/client_1/lib32. Perhaps this is a problem for you, resulting in wrong ELF class: ELFCLASS64?

      No, it's the other way round.  The lib32 is correct, but the attempt to set it didn't succeed (as explained further down in the thread).

      Carefully reading the error message

      ld.so.1: perl: fatal: /opt/oracle/product/10.2.0/client_1/lib/libclnts +h.so.10.1: wrong ELF class: ELFCLASS64

      we see that it says the library libclntsh.so.10.1 has been found in the lib/ directory (not lib32/).  Also, the runtime linker (ld.so.1) reports the incorrect ELF class (64-bit) the found library does have, not the class it should have.  From this it follows that the perl binary in question is 32-bit. In other words, lib32 is the correct path.

      </nitpick>

      Hey man,i got it resolved finally.. Thanks for your suggestions.. The issue was with LD_LIBRARY_PATH not being read properly..
      Regards,
      Blub:)