×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

the cgi script runs in commandline and not in browsers

the cgi script runs in commandline and not in browsers

the cgi script runs in commandline and not in browsers

(OP)
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

RE: the cgi script runs in commandline and not in browsers

please post the script.

adam@aauser.com

RE: the cgi script runs in commandline and not in browsers

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.
http://www.missioncriticallinux.com

RE: the cgi script runs in commandline and not in browsers

(OP)
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 "<html><body>";
print "this is the test";
#print "<b>",$startdat, "</b>","<br>\n";
#print "<b>",$enddat, "</b>","<br>\n";


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

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

#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 "<h1>","Have A Great Day","</h1>";

#print "EMPNO      EMPNAME\n";

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

#print end_html();

RE: the cgi script runs in commandline and not in browsers

you have your print end_html() commented out... maybe the browser you are testing is unhappy with that.

adam@aauser.com

RE: the cgi script runs in commandline and not in browsers

(OP)
hi lucid
i uncommented the end_html part but it is not working.
please help me

RE: the cgi script runs in commandline and not in browsers

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 http://dbi.symbolstone.org/doc/faq.html. ; This is a very good page for anyone doing anything with the DBI/DBD modules.  I hope this helps.


4.4 "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
WWW server 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:

    http://www.perl.com/perl/faq/index.html

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


 
 
 keep the rudder amid ship and beware the odd typo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close