Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Connecting to Oracle DB using DBI from CGI script

by Anonymous Monk
on Jul 05, 2010 at 06:01 UTC ( #848015=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Connecting to Oracle DB using DBI from CGI script When I run from commandline, it works fine. However, when invoked from the browser as a cgi, it fails. Could someone please help me out..

Comment on Connecting to Oracle DB using DBI from CGI script
Re: Connecting to Oracle DB using DBI from CGI script
by moritz (Cardinal) on Jul 05, 2010 at 06:24 UTC
    Tell us how it fails. Compare environment variables, and adapt them.
      https://servername.com:16316/ibm/console/webtop/cgi-bin/oracle_reporter2.cgi I am getting the blank page after this i.e Netcool : Historical Report Version 2.0 I am setting the environment like the one explained below $ENV{'ORACLE_HOME'}="/u01/app/oracle/product/10.2.0/client_1"; $ENV{ORACLE_SID}=$ORACLE_SID; $ENV{'LANG'}="C"; $ENV{'LD_LIBRARY_PATH'}="/u01/app/oracle/product/10.2.0/client_1/lib"; Please guide on this
        The first thing I always check when CLI works but web doesn't, is that I have my Content-Type line correct.
        You need two newlines after it:
        print "Content-Type: text/html\n\n";
        At least about 60% of the time for me, that fixes my main issue of not seeing anything, or rendering the page as text rather than html.
        Definitely check out marto's links, those are nice tutorials.

        If you set up Oracle environment variables inside a script that loads the Oracle client libraries, you have to set up the variables before the libraries are loaded:

        • You can set up %ENV in a BEGIN block, at least before loading DBD::Oracle implicitly via DBI->connect() or explicitly, better even before loading DBI.
        • You can wrap your script in a shell script that sets the variables before passing control to your script via exec.
        • You can add PassEnv or SetEnv directives to the Apache configuration.

        I prefer the last way, so no script has to be modified and all scripts automatically get the right Oracle configuration.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Connecting to Oracle DB using DBI from CGI script
by sierpinski (Hermit) on Jul 06, 2010 at 11:35 UTC
    You still haven't posted any error logs that I can see. That is a big help for troubleshooting this problem.

    I've verified that the minimum that you need to get a perl script visible by a webpage is the content-type line... this script works in my browser (firefox):
    #!/usr/bin/perl print("content-type: html \n\n"); print("Test");
    What *do* you see on the browser? Saying it fails doesn't really help much.
      This is the error message from webtop.log Tue Jul 06 10:04:03 EDT 2010: Tue Jul 06 10:06:22 EDT 2010: header=[co +ntent-type: text/html ] Tue Jul 06 10:06:22 EDT 2010: header=[] Tue Jul 06 11:21:04 EDT 2010: header=[content-type: text/html ] Tue Jul 06 11:21:04 EDT 2010: header=[] Tue Jul 06 11:21:06 EDT 2010: header=[content-type: text/html ] Tue Jul 06 11:21:06 EDT 2010: header=[] Tue Jul 06 11:39:06 EDT 2010: header=[content-type: text/html ] Tue Jul 06 11:39:06 EDT 2010: header=[] Tue Jul 06 11:53:44 EDT 2010: header=[content-type: text/html ] Tue Jul 06 11:53:44 EDT 2010: header=[] Tue Jul 06 11:57:39 EDT 2010: header=[content-type: text/html ] Tue Jul 06 11:57:39 EDT 2010: header=[] Tue Jul 06 11:57:41 EDT 2010: header=[content-type: text/html ] Tue Jul 06 11:57:41 EDT 2010: header=[] Tue Jul 06 12:44:27 EDT 2010: header=[content-type: text/html ] Tue Jul 06 12:44:27 EDT 2010: header=[] Tue Jul 06 12:44:30 EDT 2010: header=[content-type: text/html ] Tue Jul 06 12:44:30 EDT 2010: header=[] Tue Jul 06 12:44:33 EDT 2010: header=[content-type: text/html ] Tue Jul 06 12:44:33 EDT 2010: header=[] Tue Jul 06 12:52:51 EDT 2010: header=[content-type: text/html ] Tue Jul 06 12:52:51 EDT 2010: header=[] Tue Jul 06 12:54:44 EDT 2010: header=[content-type: text/html ] Tue Jul 06 12:54:44 EDT 2010: header=[]

      20100707 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

        From what I see, there are two entries in the log for each timestamp, so it looks like you're creating a new page with no header information. For each timestamp pair, the first one has the correct header, and the second one does not.

        Are you doing any kind of meta refresh or redirection?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://848015]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-11-29 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls