in reply to Re^10: CGI-SQL Query Issue
in thread CGI-SQL Query Issue

Hi, I do understand the proposal to check the environment, but I was looking for some workaround that could work. Now it seems like it won't, so I would check the environment. Going forward, could you please suggest what needs to be done? From Corion comments I could get this part that the user of web server doesn't has access to the Oracle libraries, or does not detect "sqlplus" commands. Also I tried to use DBI module to connect to DB in a different script, which I tried to trigger from the main script, but to no good. Could you please in particular what do I need to tell the LINUX infra team, as I just don't have any privileges in the system to do it myself. Thanks in advance for your help. Regards

Replies are listed 'Best First'.
Re^12: CGI-SQL Query Issue
by Corion (Patriarch) on Mar 18, 2016 at 16:03 UTC

    I also already linked the "Basic Debugging Checklist" for you. This list is not for admiration. It contains concrete, actionable points, and you should perform all the actions described there and inspect the results. Most actions are presented together with a rationale of which problem the action tries to diagnose. Maybe you can find out whether one of the actions diagnoses a problem you have.

      Corion, below is what I see: The code I run:
      #!/usr/bin/perl ##!/comptel/ccacp/elink/common/6.3/perl/bin/perl use strict; use warnings; #use diagnostics; use CGI; use CGI::Carp 'fatalsToBrowser'; use Data::Dumper; print Dumper(\%hash); print Dumper($ref); my $sqlfile = '/var/www/cgi-bin/dual.sql'; my $q = new CGI; my $connstr = 'id971934/colecsp@ECSP';; my $msg = qx"sqlplus -s $connstr \@$sqlfile"; print $q->header,$q->start_html, $q->pre($msg),$q->end_html; cat /var/www/cgi-bin/dual.sql select SYSDATE from dual; exit;
      ********************** This script was working properly & was giving proper results(sysdate). But when I introduced "Data::Dumper", and I try to run it from command line I get below messages
      [ccacp@el2310 cgi-bin]$ perl monkey.pl Status: 500 Content-type: text/html <h1>Software error:</h1> <pre>Global symbol &quot;%hash&quot; requires explicit package name at + monkey.pl line 9. Global symbol &quot;$ref&quot; requires explicit package name at monke +y.pl line 10. Execution of monkey.pl aborted due to compilation errors. </pre> <p> For help, please send mail to this site's webmaster, giving this error + message and the time and date of the error. </p> [Fri Mar 18 17:41:22 2016] monkey.pl: Global symbol "%hash" requires e +xplicit package name at monkey.pl line 9. [Fri Mar 18 17:41:22 2016] monkey.pl: Global symbol "$ref" requires ex +plicit package name at monkey.pl line 10. [Fri Mar 18 17:41:22 2016] monkey.pl: Execution of monkey.pl aborted d +ue to compilation errors.
      ************************** On running from web browser, I see HTTP 500 error with message "the website cant be displayed".

        Global symbol "%hash" requires explicit package name at monkey.pl line + 9.
        Nice clear message from Perl! What did you do about that?


        The way forward always starts with a minimal test.
Re^12: CGI-SQL Query Issue
by poj (Abbot) on Mar 18, 2016 at 16:28 UTC

    What error did you get from using DBI ?. Try this simple script

    #!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp 'fatalsToBrowser'; use DBD::Oracle; my $q = new CGI; my $dbh = DBI->connect( 'dbi:Oracle:host=localhost;sid=DB','USER','PASSWORD', {RaiseError => 1 , PrintError => 0} ); my ($msg) = $dbh->selectrow_array( 'SELECT CURRENT_TIMESTAMP FROM DUAL'); print $q->header,$q->start_html, $q->h2($msg),$q->end_html;
    poj
      Hi, What DB, USER & PASSWORD do I need to use? I don't see DB entry in your connect string. Anyways, I adapted USER & PASSWORD info & it threw HTTP 500 error. Regards

        Try the same username/password/sid as your SQLplus connection.
        Run this to compare the web and command line environments

        #!/usr/bin/perl use strict; use warnings; use Data::Dumper; print "Content-type: text/plain\n\n"; print Dumper \%ENV;
        poj