Solved

why a cgi works an other don´t?

Posted on 1998-07-09
5
224 Views
Last Modified: 2013-12-25
i have two cgi scripts in perl accessing to a database, both of them works in the command line but one of then
not in a web server (apache 1.3b7 on win nt);

this script works in the command line and in the web server: (SQL Server)

#!c:\perl\bin\perl.exe

require 5.004;
use DBI 0.90;
$dbh = DBI->connect('dbi:ODBC:ms','xxx', 'xxxx',{RaiseError=> 1})
  or die $DBI::errstr;
$cursor = $dbh->prepare("SELECT * FROM tabla");
$cursor->execute;
@col=@{$cursor->{NAME}};

print "Content-type:text/html\n\n";
print "<html>\n<head>\n</head>\n<body bgcolor=#fffff3>\n";
print "<center><table border=2>";
$a=$#col+1;
print "<tr>";
for($i=0;$i<$a;$i++){
print "<td>$col[$i]</td>";
}
print"<tr>";
print"</table>";
print"</body></html>";
$cursor->finish();
$dbh->disconnect();

this script only works in the command line: (Oracle 8.0.3):

#!c:\perl\bin\perl.exe

require 5.004;
use DBI 0.90;
$dbh = DBI->connect('dbi:ODBC:ora', 'xxx', 'x',{RaiseError=> 1});
$cursor = $dbh->prepare("SELECT * FROM tabla");
$cursor->execute;

@col=@{$cursor->{NAME}};

print "Content-type:text/html\n\n\n";
print "<html>\n<title>oracle</oracle>\n<head>\n</head>\n<body bgcolor=#fffff3>\n";
print "<center><table border=2>";
$a=$#col+1;
print "<tr>";
for($i=0;$i<$a;$i++){
print "<td>$col[$i]</td>";
}
print"<tr>";
print"</table>";
print"</body></html>";
$cursor->finish();
$dbh->disconnect();

0
Comment
Question by:isi
  • 3
5 Comments
 
LVL 6

Expert Comment

by:alamo
ID: 1830605
The most likely reason is that accessing Oracle requires a support file (DLL for example) whose file rights aren't set properly, so that the user the server runs as has access to them.

Unfortunately I don't know the details of Apache setup on NT so I don't know who the server runs as. But you could test by either setting the server to run as you or by logging in as the user server runs as and trying to run the script from the shell. (this is for test only, not a good idea to run that way).

Also possible, though less likely, is that something in the Oracle setup is path-dependent... try putting the script in the path and running it from a different directory.

Hope this helps.
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830606
One more thing.. I have a vague recollection from my days working with Oracle that it sometimes read environment strings to get configuration info... you could look at that, too.
0
 

Accepted Solution

by:
wrussell051197 earned 100 total points
ID: 1830607
check your HTML. I've found that many scripts APPEAR not to run correctly from the browser because they are not sending proper HTML. If the second script is a cut and paste, then the problem may be the lack of closing the title container </title>. I've found these problems a lot when working with very complex CGI programs, and I assume it would be the same for pearl scripts.
0
 

Author Comment

by:isi
ID: 1830608
thank you for all,
but this error was because, i had an error writing my e-mail.
al last i found the solution, the alamo coment was near the solution.
i have change my web server, that recognize all enviroment vars, and all my scripts
works,
thanks
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830609
FYI isi, the proper way on Experts Exchange to handle a situation like this is to reject the current answer which is wrong and ask the person who made the comment which helped you solve the problem to post an answer, which you then grade.

Many experts here hesitate out of courtesy to post an "answer" unless they are certain of the problem, preferring to post a comment first and only post an answer when the questioner has responded that the suggestion worked. In this case, I am not thrilled that you used my suggestion but I got nothing, and I bet wrussell is not thrilled he got a grade of D. It's done now, and can't be undone, but I thought you should know for your future dealings on E-E how things work.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now