Solved

why a cgi works an other don´t?

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
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 …

690 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