Solved

why a cgi works an other don´t?

Posted on 1998-07-09
5
228 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

733 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