Solved

why a cgi works an other don´t?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Update a File not in all folders 2 43
Non root SFTP users cannot log in - Software caused connection abort 15 75
User profile Size Report 3 63
Bulk Reorder File Names 4 55
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
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 …

911 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

18 Experts available now in Live!

Get 1:1 Help Now