Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl/CGI help 1

Status
Not open for further replies.

holidayIT

IS-IT--Management
Apr 2, 2004
138
0
0
US
I setup perl on a windows 2003 box with iis 6. i followed instructions from visualwin.com and wrote 4 test scripts. all my perl and cgi scritps work in a command prompt, but not in IE. I get the misbehaved not return complete http header error. my fisrt line after the shebang line is
print "Content-type: text/html\n\n";
in most of my scripts. nothing works. can anyone help me please????
 
use warnings;
use strict;
use CGI; ##### Bring CGI module into program
use CGI::Carp qw(fatalsToBrowser); ### displays all errors onto browser
my $q = new CGI;

my $dbh = DBI->connect( 'dbi:mysql:host=xxxxxxxx; sid=xxxx;port=xxxxx',
'user',
'pass', { RaiseError => 1, AutoCommit => 0}
) || die "Database connection not made: $DBI::errstr\n";

my $start =$q -> param('Num');

if ($start)
{

my $sql_A=qq{ SELECT sname from employee where id = '$start'};

my $sth_A = $dbh->prepare ($sql_A)|| die "Prepare failed: $DBI::errstr\n";
$sth_A->execute() || die "Couldn't execute query:$DBI::errstr\n";


print "Content-Type: text/html\n\n";
print "<html><body>";
print "<BODY leftmargin=0 topmargin=0>";
print "<table height=\"100%\" width = \"100%\" cellpadding = \"0\" cellspacing = \"0\" border = \"2\" align = \"center\">";
print "<tr height=\"5%\">";
print "<td align = \"center\" colspan =\"2\" bgColor=\"blue\">";
print "<FONT face=\"Times New Roman\" size=\"5.5\" Color =\"White\"> Result </font>";
print "</td>";
print "</tr>";
print "<tr height=\"90%\">";
print "<td width = \"100%\" colspan = \"2\">";
print "<br>";
print"<br>";
print "<table align=\"center\" bgcolor=\"#E5EEF3\" border=2 bordercolor=\"navy\" >";
print "<tr>";
print"<td><b> Employee Name</b></td>";
while (my @row= $sth_A->fetchrow_array())
{

foreach my $my_td (@row) { print "<td>$my_td</td>\n"; }

}
$sth_A->finish();
print "</tr>\n";
print "</table>";
print "<br>";
$dbh->disconnect() || die "Failed to disconnect\n";
print "<br>";
print "<tr height=\"5%\">";
print "<td align = \"center\" colspan =\"2\" bgColor=\"navy\">&nbsp;</td>";
print "</tr>";
print "</table>";
print "</body></html>";
}

else

{
print "Content-Type: text/html\n\n";
print "<html><body>";
print "<BODY leftmargin=0 topmargin=0>";
print "<table height=\"100%\" width = \"100%\" cellpadding = \"0\" cellspacing = \"0\" border = \"2\" align = \"center\">";
print "<tr height=\"5%\">";
print "<td align = \"center\" colspan =\"2\" bgColor=\"navy\">";
print "<FONT face=\"Arial\" size=\"5.5\" Color =\"White\"> Error </font>";
print "</td>";
print "</tr>";
print "<tr height=\"90%\">";
print "<td width = \"100%\" colspan = \"2\">";
print "<table align=\"center\" bgcolor=\"aliceblue\" border=2 bordercolor=\"navy\" >";
print "<tr>";
print "<td><b>No Data were entered , Please go back and enter data again !! </b></td>";
print "</tr>";
print "</table>";
print "<A href= Go Back </B>";
print "<tr height=\"5%\">";
print "<td align = \"center\" colspan =\"2\" bgColor=\"navy\">&nbsp;</td>";
print "</tr>";
print "</table>";
print "</body></html>";
}

---------------------------------------------------------------------------------------------------------------------------------------------
let us know if still more information is needed
Happy Coding :)
ronan
 
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.

This is all i get from any kind of cgi or pl

i have absolutely no idea what is wrong. in the comamnd prompt it works great. i am guessing that i didn't setup iis correctly, but i have the mappings correct, the virtual directory is set, the extensions are allowed, permissions are set. what else am i missing?

i will give you my first born
 
[Wed May 26 11:03:39 2004] test5.pl: Can't locate object method "connect" via pa
ckage "DBI" at test5.pl line 8.

this is what i get from the command line. sorry, i forgot to include that (still wont run in IE)
 
You never include DBI.pm

put

Code:
use DBI;

before you try to run DBI->connect
 
Try the simple stuff first.
Paste

print "<HTML><HEAD>";
print "<TITLE>test</TITLE>";
print "</HEAD>";
print "<BODY>";
print "<H1> testing</H1>";
print "</BODY>";
print </HTML>";
 
my first test was this:
#!C:/Perl/bin/perl
print "Content-type: text/html\n\n";
print "Hello World\n";

my second was this:
#!perl
print "Content-type: text/html\n\n";
print "Hello World\n";

and then this:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello World\n";

i figure if i can get this to work, everything else is sytax or coding issues. but with all of this i still get the CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.

 
I pulled this off of a google search. Don't know if this will help. I read another solution saying that your version of PERL may be corrupted and to uninstall, then reinstall PERL.

Anyway, for what it's worth:

SYMPTOMS
When you run a PERL script with Microsoft Internet Information Server (IIS), you may get the following error:

CGI Error:

The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

Cannot load advapi32.dll.

However, the PERL script will run without errors from the command line without using IIS.
CAUSE
The Advapi32.dll file is used by PERL and in turn, tries to open another DLL in the Microsoft Windows NT System32 directory. If it fails to load the DLL in \System32, Advapi32.dll will also fail to load causing the above error message.
WORKAROUND
The credentials of the IUSR_servername (IIS anonymous account) are used to access the Windows NT System directories. If this account does not have sufficient privileges to a file or directory, PERL or other CGI scripts may fail to execute.

Check the permissions on the Winnt\System32 directory and make sure the IUSR_servername account has sufficient access.



There's always a better way. The fun is trying to find it!
 
i hate to say it, but i did try to find that, and unfortunately, i cannot find the IUSR_servername account anywhere. i tried to find it when i first setup the cgi-bin in iis. i tried adding it, but it isn't listed. i get IUSR from two other servers, but not the server that holds iis.

I am not using iis as a public web server, it is for an intranet private website. authentication is handled through ads.

I think that what you said is, in fact, my problem. Do you know, by any chance, how i can create the IUSR_servername account for this server??? (guessing that it is disabled somewhere)

sorry to be a pain
 
Sorry, I don't know much about IIS - except that it's the main target for hackers who seem to be quite successful at finding the holes that Microsoft can't seem to plug. Personally, I use Apache on all my systems and have never had a single problem.

If I were you, I'd plan on spending some time at Microsoft's knowedge base. Also, you might want to try the IIS forum.

There's always a better way. The fun is trying to find it!
 
i am not getting the error with the dll. there is no other information other than:

The specified CGI application misbehaved by not returning a complete set of HTTP headers.

I know it must be a security issue, and iis 6 doesn't use the iislockdown tool.
 
tviman, i really appreciate your help, man. unfortunately those didn't work. thanks though.
 
You still never included DBI in your code.

That means that when you try to connect it will fail.

Code:
use DBI;
 
Siberian... I wouldn't think that would cause the error he's getting. It sounds more like an IIS, or even a W2003 Server configuration problem.

There's always a better way. The fun is trying to find it!
 
The error you are getting is

Code:
[Wed May 26 11:03:39 2004] test5.pl: Can't locate object method "connect" via pa
ckage "DBI" at test5.pl line 8.

this is what i get from the command line.  sorry, i forgot to include that (still wont run in IE)

That to me says perl can't find DBI.

But I've never run perl under IIS so all bets are off, I've just never been able to access DBI commands without first including the lib.
 
that was from a script given to me to test at the top of the thread. my error is iis. not even a hello world script will work.

what i did was setup iis and cgi-bin on a win2k box, and point my html to that site/cgi-bin

that worked. now it's just a question of getting formmail to work with either net::smtp or blat (neither seem to want to work)

Thanks to everyone for their help. i really appreciate it. i still dont know what the problem was/is, but i will say that if you are ever given a choice to use server 2000 or server 2003, go with 2000....you will live longer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top