Re: Perl, Oracle, and a browser

From: Dodger <dodger_at_dodger.org>
Date: Sat, 15 Dec 2001 23:52:41 GMT
Message-ID: <Xns9178BFECD88E9dodgerdodgerorg_at_24.12.106.199>


Yurasis Dragon <spam_at_smeagol.com> wrote in news:nfmg0ucbve6sccavr30t76kod4nem23d13_at_4ax.com:

> I'm playing with Perl and DBI and Oracle DBD and have
> been able to get my Perl script read an Oracle database
> and output the results at the command line.
>
> However, once I put the script in the cgi-bin and try to
> run it from a browser, I get not output ( can't remember
> the exact message, sorry ).
>
> I dug around a little more and found that I need to add
> something like :
>
> print "Content-type: text/plain\n\n" ;
>
> So I added that code ... but still no output to a browser.
>
> I wrote a small Perl script, a "hello world" type, and added the
> above line and the script output to a browser, no problem.
>
> It seems to be when I try to connect to an Oracle database
> that I have the problem. So I ran the script at the command
> line as root and found that it did not run correctly until I defined
> ORACLE_HOME.
>
> So this leads me to suspect that Apache needs to know about
> ORACLE_HOME in order for my Perl script that accesses an Oracle
> database to work in a browser.
>
> So the question is where do I define ORACLE_HOME and how. Is
> it something like "SetEnv ORACLE_HOME /oracle/product/8.1.7"
> added in httpd.conf?
>
> I think that I can do a similar thing in my Perl script directly ( I'm
> pretty new to Perl but do recall that I can set an environment variable
> in Perl ) but I don't want to have to do that to every Perl script, a
> more global solution is preferable and much more elegant.
>
> Any suggestions? Thanks in advance.

BEGIN {

    $ENV{ORACLE_BASE}='/u01/app/oracle'; # replace with $ORACLE_BASE
    $ENV{ORACLE_SID}='sid'; # replace with your default SID
    $ENV{ORACLE_OWNER}='oracle'; # replace with your $ORACLE_OWNER
    $ENV{ORA_LOG}='/home/oracle/log'; # replace with your log path
    $ENV{ORACLE_HOME}='/u01/app/oracle/product/8.0.5'; # replace with your 
$ORACLE_HOME
    $ENV{ORA_UTIL}='/home/oracle/util';} # replace with your oracle util directory
-- 
Dodger
Received on Sun Dec 16 2001 - 00:52:41 CET

Original text of this message