Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

why a cgi works an other don´t?

Posted on 1998-07-09
5
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

618 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