Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Perl, Oracle, and a browser

15 views
Skip to first unread message

Yurasis Dragon

unread,
Nov 30, 2001, 11:29:02 PM11/30/01
to
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.


===
Yurasis Dragon
sp...@smeagol.com

Ron Reidy

unread,
Dec 1, 2001, 9:42:11 AM12/1/01
to
Your question is off topic for these groups. This is not an Oracle
issue, but a web issue. However, you need to read the doco for CGI.pm
(it should be installed, if not, get it from cpan). If that fails to
enlighten you, look at the Perl newsgroup's archives for your answers.
--
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.

KandoCoder

unread,
Dec 2, 2001, 6:26:54 PM12/2/01
to
Yes, wrong forum, just keep this in mind.
When I run a CGI on a UNIX box from the web, I'm running it as use "nobody"
usually.
Therefore user "nobody" must have all the environment variables/paths and
roles/permissions required to do the job....

Yurasis Dragon <sp...@smeagol.com> wrote in message
news:nfmg0ucbve6sccavr...@4ax.com...

Yurasis Dragon

unread,
Dec 2, 2001, 8:59:15 PM12/2/01
to

Thanks for the help guys.

Note how all the help came from the "wrong" group. Looks like
I made the correct choice for the very reason that I posted in the
comp.databases.oracle.tools group. Oracle people who work with
a webserver would have the answer I'm looking for.

Thanks again.


Yurasis Dragon <sp...@smeagol.com> :


===
Yurasis Dragon
sp...@smeagol.com

KandoCoder

unread,
Dec 2, 2001, 11:14:45 PM12/2/01
to
Well actually, many of us have that multiple hat syndrome.
(Let's see what's the next phone call? Networking, DBMS, UNIX, Printers or
Windoze - or maybe I got to freaking fix the VCR again...)

Yurasis Dragon <sp...@smeagol.com> wrote in message

news:hrml0usvvfm76va51...@4ax.com...

Robert Chin

unread,
Dec 3, 2001, 1:36:18 AM12/3/01
to
Strange...your return email address...
seems to me any answers are gonna get mixed
with your spam and get deleted...oh well...

Anyway...oracletool.com has an open source Perl/Oracle
project...I guess Perl junkies can learn a lot.

Robert Chin

Yurasis Dragon

unread,
Dec 3, 2001, 8:48:30 AM12/3/01
to
Thanks for the oratool.com, I had never heard of it.

BTW, I have a special e-mail address that I use, sp...@smeagol.com,
that I use whenever I have to give up an e-mail address at
a web-site, etc. - this way non-important e-mail doesn't get mixed
with "important" e-mail. Then I check sp...@smeagol.com whenever
I expect e-mail that I may need to read ... it works for me.


Shrieking in pain from a horribly disfigured body, "Robert Chin" <robert_c...@hotmail.com> groaned :


===
Yurasis Dragon
sp...@smeagol.com

Dodger

unread,
Dec 15, 2001, 6:52:41 PM12/15/01
to
Yurasis Dragon <sp...@smeagol.com> wrote in
news:nfmg0ucbve6sccavr...@4ax.com:

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

Benjamin Goldberg

unread,
Dec 16, 2001, 1:16:32 AM12/16/01
to
Yurasis Dragon wrote:
[snip]

> 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.

Close. The ORACLE_HOME environment variable needs to be set when the
database driver for Oracle is loaded. There's two ways to do this:
either have it set in the envrionment which starts up the perl program,
or set it within the perl program sometime before you load the database
driver. If your program is running as a CGI, then to have that variable
set in the environment before perl starts, it would have to be done via
the web server.

> 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?

That's one way to do it.

> 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.

If you put all your environment settings in a single perl file, perhaps
called My_Ora_Config.pm, then you could simply add a line "use
My_Ora_Config;" some point before the line which says "use DBI;"

Inside of My_Ora_Config.pm you would have a line like the following:

$ENV{ORACLE_HOME} = "/oracle/product/8.1.7"

And maybe some other environment settings.

Of course, you still would have to add the "use" line to every script
which uses DBI, so maybe that's not so hot an idea. I would go with
putting the line in httpd.conf

--
Klein bottle for rent - inquire within.

0 new messages