[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 910
  • Last Modified:

Cannot use Perl script in IIS 6

Hi
I've encountered such a weird problem that made me actually dislike IIS more! Can you please help?
I, initially, have everything on Linux and Solaris, then we need to change to use windwos server 2003 for developers to work easily.

I installed IIS 6 and ActivateState ActivePerl 5.8, I went through all the Web Service Extension, Configurations to ensure that things look good. I also set IUSR_**** user to have EXECUTE permission upon the folders that contain *.pl files.

The scripts being copied from Linux server did not work, and I received "The specified CGI application misbehaved by not returning a complete set of HTTP headers."

Therefore, I set out to do some testings with the simplest code ever "welcome to perl"
The code below works okay.
if I change it to something that is shorter like this:
----------------------------------------
print "HTTP/1.0 200 OK";
print "Content-Type: text/html";

print "Perl Test Page";

print "This is a test";
-----------------------------------------
Then I will got the CGI error like above.!@ Although, command-line execution of the script is done nicely.

Can you please give me some insight?
If IIS cannot execute such simple form, more complex form (database query, html form handling...) won't work either.  
thanks millions!

##### THIS CODE WORKS OKAY AS I COPIED FROM INTERNET 
print "HTTP/1.0 200 OK
";
print "Content-Type: text/html
 
";
print "
";
print "
";
print "Perl Test Page
";
print "
";
print "
";
print "This is a test
";
print "
";
print "
";
print "
";
###############

Open in new window

0
valleytech
Asked:
valleytech
  • 8
  • 4
  • 2
  • +2
1 Solution
 
TintinCommented:
The MIME header needs to be separated from the output by a blank line, so you should do

print "Content-Type: text/html\n\n";

However, if you are going to be writing Perl/CGI scripts, make sure you use the CGI module.
0
 
Praveen DMInfra Team LeadCommented:
Configure PERL Script Mapping for IIS 6.0

1. Click Start, click Programs, click Administrative Tools, and then click Internet Information Services.
2. Right-click a Web site that you want to enable PERL for, and then click Properties.
3. Click the Home Directory tab.
4. Click Configuration.
5. Click Add.
6. In the Executable box, type the following:
full path to perlis.dll\perlis.dll
You can also type the following:
full path to perl.exe\perl.exe %s %s
Note The "%s %s" is case sensitive (for example, "%S %S" does not work).
7. In the Extension box, type .pl.

Note Make sure that the All Verbs option is selected for full functionality. Also, make sure that the Script Engine check box is selected.
8. Click OK to return to the ISM.
9. Click the Web Service Extensions folder.
10. Click Add a new Web service extension.
11. Type a name for the extension, such as "PERL Scripts."
12. Click Add, type the full path to the Perl.exe file, and then click OK.
13. Make sure that the Set extension status to Allowed check box is selected.
14. Click OK to return to the ISM. With the IIS default scripts directory, the URL is the following:  

Chec option " Enable Scripts and Executables " too... Thank U
0
 
valleytechAuthor Commented:
Thanks!1
How can I know that I'm using CGI module? I guess the installer from ActiveState would do all the jobs for me.
I saw that there were "Perl CGI extension", "Perl ISAPI extension" and "PerlEX extension" they're all enabled.
but in LInux, I really don't have to use header though.
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
Praveen DMInfra Team LeadCommented:
Enabled will do --Perl CGI extension   ..... Are you still facing problem and

Is this done..

Right-click the virtual directory and select Properties. On the Mappings tab of the Application Configuration page, ensure that the    .pl &  .cgi     extension is mapped to the Perl interpreter.
0
 
valleytechAuthor Commented:
the *.pl extension was added automatically by ActivePerl and it's using perl.exe %s %s
I don't see the *.cgi extension mapping though, will it cause problem?

Thanks for the advise on a line separation of HTTP header, now I can get the test.pl file working well.
0
 
valleytechAuthor Commented:
This is the file that I'm having issue with - the code is pretty lengthy
I have not spotted any thing suspicious, yet it's been working under my linux platform.
I just added the http header too, but still the same error

thanks!!!
##
##  fowp -- FileOpen WebPublisher
##	January 31, 2002
##
print "HTTP/1.0 200 OK\n\n";
 
use strict;
use CGI qw(:standard);
use Time::Local;
use Time::localtime;
use Socket;
use Mysql;
$DBHOST = "192.168xxx";
$DBNAME = "xxxxxx";
$DBUSER = "MAIN";
$DBPASS = "aaaa";
 
	$ip = $ENV{'REMOTE_ADDR'}; 
.........................
if ( $call_return eq "1" )
  {
    print <<END_HTML;
     <html>
  <head><title>text goes here</title>
  <META http-equiv="Content-Style-Type" content="text/css">
  <STYLE type="text/css">
    .title {font-size: 16pt; color: red; font-family: Helvetica;}
    H2 {font-size: 10pt; color: black; font-family: Helvetica;}
    H5 {font-size: 12pt; color: navy; font-family: Helvetica;}
    H3 {font-size: 12pt; color: red; font-family: Helvetica;}
    H4 {font-size: 14pt; color: red; font-family: Helvetica;}
  </STYLE>
  </head>
  <body><center>
  <table width="98%">
	<tr>
		<td class="title">Thank you</td>
		<td align="right">
  <img src="dmain.gif">
		</td>
	</tr>
  </table>
    <H3> text goes here.</H3>
<br>
    <br>
   <!-- <H5> text goes here</H3><br.<br>-->
 
<H4> Did you know?</H4>
<br>
<H5>
 
 
text goes here.<br><br>
 
 
 
Click the following link to be taken directly to your product's tutorial: <a href="http://www.domain.com/learn">http://www.domain.com/learn</a> </H5>
 
</center>
    </body></html>
END_HTML
  }
......

Open in new window

0
 
TintinCommented:
Remove the line

print "HTTP/1.0 200 OK\n\n";

As the Perl CGI module will handle HTTP and MIME headers for you, as well as NPH output (which is required for some IIS servers).


If you want to view the error in the browser, add the line

use CGI::Carp 'fatalsToBrowser';

In your case, you aren't outputing a MIME header, so, before your if test, add the line

print header;
0
 
valleytechAuthor Commented:
Thanks!!
but without the print HTTP header, I will receive the error even with such simple script at test.pl

0
 
saurabhpendharkerCommented:
Hello,
Please try these headers:
   print "HTTP/1.0 200 OK\n";
   print "Content-Type: text/html\n\n\n";
0
 
valleytechAuthor Commented:
thanks!
i've tried that several times with the header, my test.pl work just fine. Without it, i will receive "misbehaved" error.

with/without the header, I still get that error when trying with the complex file.
0
 
TintinCommented:
As previously explained, when you are using the Perl CGI module, it takes care of the HTTP/MIME headers for you.  It has a lot of smarts built in to know which headers to output.

Here's how your script should look
##
##  fowp -- FileOpen WebPublisher
##      January 31, 2002
##
use strict;
use CGI qw(:standard);
use CGI::Carp 'fatalsToBrowser';
use Time::Local;
use Time::localtime;
use Socket;
use Mysql;
my $DBHOST = "192.168xxx";
my $DBNAME = "xxxxxx";
my $DBUSER = "MAIN";
my $DBPASS = "aaaa";
 
my $ip = $ENV{'REMOTE_ADDR'}; 
 
print header;
 
# Note that $call_return is not defined anywhere, so this
# will cause an error.
if ( $call_return eq "1" )
  {
    print <<END_HTML;
     <html>
  <head><title>text goes here</title>
  <META http-equiv="Content-Style-Type" content="text/css">
  <STYLE type="text/css">
    .title {font-size: 16pt; color: red; font-family: Helvetica;}
    H2 {font-size: 10pt; color: black; font-family: Helvetica;}
    H5 {font-size: 12pt; color: navy; font-family: Helvetica;}
    H3 {font-size: 12pt; color: red; font-family: Helvetica;}
    H4 {font-size: 14pt; color: red; font-family: Helvetica;}
  </STYLE>
  </head>
  <body><center>
  <table width="98%">
        <tr>
                <td class="title">Thank you</td>
                <td align="right">
  <img src="dmain.gif">
                </td>
        </tr>
  </table>
    <H3> text goes here.</H3>
<br>
    <br>
   <!-- <H5> text goes here</H3><br.<br>-->
 
<H4> Did you know?</H4>
<br>
<H5>
 
 
text goes here.<br><br>
 
 
 
Click the following link to be taken directly to your product's tutorial: <a href="http://www.domain.com/learn">http://www.domain.com/learn</a> </H5>
 
</center>
    </body></html>
END_HTML
}

Open in new window

0
 
valleytechAuthor Commented:
Thanks millions! I was able to diagnose the problem and install missing modules ...
After that... I got this error
"Global symbol "%hash1" requires explicit package name at hashs.pl line 6.
Global symbol "%hash2" requires explicit package name at hashs.pl line 7."

I have to remote "use strict" to avoid this.
Can you please teach me what was going wrong??

thanks!
0
 
TintinCommented:
I'm assuming you didn't post the full script.  When you have 'use strict' specified, it forces you to declare all your variables.  This saves you time when debugging scripts due to silly typos.

Have a read of http://perl.plover.com/FAQs/Namespaces.html for a good description.
0
 
valleytechAuthor Commented:
yes..the script is 1000-line long, posting it fully will be quite annoy for you experts. ;)
then I assume that removing "use strict"  won't affect anything?

0
 
Adam314Commented:
The use strict will help prevent you from making certain mistakes.  If the script doesn't work with use strict, it could be a problem with the script.  It would be better to get the script working with use strict than to remove it.
0
 
valleytechAuthor Commented:
sorry for being late not to respond ..
a result of attending full-time grad school

it works like charm now!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 8
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now