Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the cgi script runs in commandline and not in browsers

Status
Not open for further replies.

ktsrikanth

Programmer
Feb 6, 2001
22
0
0
US
the cgi script is written to display the data from the database(oracle 8). when tested on the commandline, the data is retrieved but when tested on the browsers like ie, netscape there is no data. please send the solution
 
Many times this can be due to a file permissions problem, or a webserver configuration problem. Make sure your webserver is configured properly to run cgi scripts - can you successfully run other cgi scripts? Or is it failing when you try to run *any* cgi script?

Since the webserver usually(?) runs as an unprivileged user(like "nobody"), and since your cgi scripts probably are owned by a more privileged user, make sure your cgi script permissions allow the script to be run by the user that the webserver is running under.

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
hi luciddream
i am posting the script to u
#!/usr/local/bin/perl

use CGI;
use DBI;

#&CGI::ReadParse;
#my $startdat = $in{startdate};
#my $enddat = $in{enddate};

#print header();
#print start_html();
print "Content-type:text/html\n\n";
print &quot;<html><body>&quot;;
print &quot;this is the test&quot;;
#print &quot;<b>&quot;,$startdat, &quot;</b>&quot;,&quot;<br>\n&quot;;
#print &quot;<b>&quot;,$enddat, &quot;</b>&quot;,&quot;<br>\n&quot;;


#declaring variables
my $country='New Zealand';

my $dbh = DBI->connect('dbi:Oracle:wdu1','smsweb2','smsweb2')||die &quot;database connection not complete:$dbh::errstr\n&quot;;
print &quot;connected to the database&quot;;

#print $dbh;

#my $sql=qq { select up_first_name,cm_country_name from cm_user_profile,cm_login,cm_country_master,cm_keys where cm_user_profile.up_userid=cm_login.lo_userid and cm_country_master.cm_country_name='$country' and lo_user_status='ACTV' and cm_keys.ke_entered_date between to_Date('$startdat','mm/dd/yy') and to_Date('$enddat','mm/dd/yy') and cm_user_profile.UP_userid=cm_keys.ke_userid };

my $sql = qq{ select msgtype from messagehistory };
print($sql);
my $stmt = $dbh->prepare($sql);

$stmt->execute();

#my($no,$name);
my($name);

$stmt->bind_columns(undef, \$name);
#print &quot;<h1>&quot;,&quot;Have A Great Day&quot;,&quot;</h1>&quot;;

#print &quot;EMPNO EMPNAME\n&quot;;

while($stmt->fetch())
{
#print &quot;<b>&quot;,$no, &quot;</b>&quot;,&quot;<br>\n&quot;;
print &quot;<b>&quot;,$name, &quot;</b>&quot;,&quot;<br>\n&quot;;
#print &quot; $no $name \n&quot;;
}
print &quot;<h1>&quot;,&quot;Have A Great Day&quot;,&quot;</h1>&quot;;
$stmt->finish();
$dbh->disconnect();

#print end_html();
 
you have your print end_html() commented out... maybe the browser you are testing is unhappy with that. adam@aauser.com
 
hi lucid
i uncommented the end_html part but it is not working.
please help me
 
I was suspicious that when you ran the code from the command line it was using some of you environmental variables upon which Oracle communication is dependent. And, that the web daemon, running as 'nobody', probably, might not have those variables set. I found the following and cut/pasted it from This is a very good page for anyone doing anything with the DBI/DBD modules. I hope this helps.


4.4 &quot;When I run a perl script from the command
line, it works, but, when I run it under the httpd, it
fails!'' Why?


Basically, a good chance this is occurring is due to the fact that the user that you
ran it from the command line as has a correctly configured set of environment variables, in the case of DBD::Oracle, variables like ORACLE_HOME, ORACLE_SID or TWO_TASK.

The httpd process usually runs under the user id of nobody, which implies there is no configured environment. Any scripts attempting to execute in this situation will correctly fail.

One way to solve this problem is to set the environment for your database in a
BEGIN { } block at the top of your script. Another technique is to configure your
to pass-through certain environment variables to your CGI scripts.

Similarly, you should check your httpd error logfile for any clues, as well as the ``Idiot's Guide To Solving Perl / CGI Problems'' and ``Perl CGI Programming FAQ''
for further information. It is unlikely the problem is DBI-related.

The ``Idiot's Guide To Solving Perl / CGI Problems'' can be located at:


as can the ``Perl CGI Programming FAQ''. Read BOTH these documents carefully!


keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top