CGI ERROR Message

DESCRIPTION: I have ActivePerl installed on a MS Server 2003 machine. I have created a cgi-bin and have some scripts in it. when I run the following test script I get an error:
http://www.csscsystems.com/cgi-bin/env.pl 

QUESTION: How do I correct this error message?
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
cssc1Asked:
Who is Participating?
 
MorcalavinCommented:
Are you printing the header?  Try this script:

#!c:/path/to/perl.exe

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

print "Hello, world!";
0
 
MorcalavinCommented:
Also, make sure your script has execute permissions and the the perl executable itself has execute permissions.
0
 
cssc1Author Commented:
Question: How is this done?
Also, make sure your script has execute permissions and the the perl executable itself has execute permissions.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
MorcalavinCommented:
I'm assuming you have access to log into the server.  Use windows explorer and navigate to the perl script/perl executable.  Right click on it. Go to properties, then click on the security tab.  Find the user that your web server is run under(usually something like IIS_USER or something similar), and make sure they have "Read and Execute" permissions checked.
0
 
cssc1Author Commented:
HERE IS WHAT I DID:
Setting up Perl/CGI to work with Windows Server 2003

The following things are assumed:

You are running Windows Server 2003
IIS 6.0
You installed ActiveState ActivePerl (http://www.activestate.com) to C:\Perl UPDATE: ActivePerl 5.8.2 Build 808 and higher should add the Web Service Extensions during install
You are using default (unmodified) ACLs/Permissions
Also, all of my reasoning is explained after the step-by-step is done, at the bottom of the page.

Load IIS from the Administrative tools in the Control Panel by clicking Start -> Administrative Tools -> IIS Manager (or loading the Control Panel, entering the Administrative Tools folder, and double clicking IIS Manager).

 

Click the name of your computer then click "Web Service Extensions", on the left side of the main frame you will see a green arrow pointing to a link that says "Add a new Web service extension...", click that link.



In that window, where it asks for the extension name you can put anything, like "CGI script" and under the "Required Files" section put the following in (without the apostrophes) 'C:\Perl\bin\perl.exe "%s" %s' click OK to the notification, click "Set status to allowed" and press ok.



Now, load up a command prompt (Start->Run... type cmd) and type (without the quotes) "md c:\inetpub\cgi-bin"



Back in the IIS Manager right click Default Web Site highlight "New" in the pop-up menu and click "Virtual Directory..." in the new menu



Click next to the first dialog in the wizard, then as a the alias put "cgi-bin" and click next then as a path for the next dialog put in "c:\inetpub\cgi-bin".  On the next dialog leave everything checked and check execute and click next



Click Finish to end the wizard.

Now right-click cgi-bin and click properties



Click Configuration in the lower right-hand area of the dialog and make sure .pl is there (if it isn't, add it the way you see it)



Making your scripts work

To make your scripts work the shebang line (#!/usr/bin/perl) should now be #!C:\Perl\bin\perl.exe .  Any reference to any files should be changed from /home/user etc, to c:/home/user or c:\\home\\users - note the double back-slashes.

Also, renaming your .cgi scripts to .pl is highly recommended - it's what I do myself ;-)

Assuming this is all done correctly, you should now be able to run your Perl scripts successfully using Windows Server 2003, and IIS 6.0

0
 
MorcalavinCommented:
Have you tried the script above that I gave you?  Are you still getting an error message after setting execute permissions on the executable and script?
0
 
cssc1Author Commented:
I don't know how to try the script you gave me. Please give me a cut and past script I can paste into my address bar.
0
 
MorcalavinCommented:
That won't do you any good.  You need to test it on your server.  copy this:
#!c:/path/to/perl.exe

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

print "Hello, world!";


Now log into your server and save it as test.pl.  Make sure the test.pl script has execute permissions.  Save it in your cgi-bin.  now you should be able to go to http://www.csscsystems.com/cgi-bin/test.pl and see if the script works.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.