Solved

Can CGI be used in IIS and how can I enable IIS to use CGI script

Posted on 2000-03-21
28
364 Views
Last Modified: 2013-12-25
Can CGI be used in IIS and how can I enable IIS to use CGI script. I am running Windows NT Server 4.0. My CGI script just do not work on my webpage.
I also used VBscript and Frontpage and ASP for my web page. I created it in PWS it worked fine but after I transfer it to IIS it just do not work
0
Comment
Question by:da511
  • 14
  • 11
  • 2
  • +1
28 Comments
 
LVL 16

Expert Comment

by:maneshr
ID: 2641249
sure you can use CGI with IIS. if you are using/plan to use PERL for CGI scripting, here how you configure and test a PERL Script with
Internet Information Server (IIS)

============================================
Configuring and Testing a PERL Script with Internet Information Server (IIS)

SUMMARY

  The following PERL script can be used to test for the proper installation and execution of CGI scripts with Internet Information server.

MORE INFORMATION

  Create a file with Notepad, and type the following lines of code. Save the file in the scripts
  directory as Helloworld.pl.

  print "HTTP/1.0 200 OK\n";
  print "Content-Type: text/html\n\n";

  print "<HTML>\n";
  print "<HEAD>\n";
  print "<TITLE>Hello World</TITLE>\n";
  print "</HEAD>\n";
  print "<BODY>\n";
  print "<H4>Hello World</H4>\n";
  print "<P>\n";
  print "Your IP Address is $ENV{REMOTE_ADDR}.\n";
  print "<P>";
  print "<H5>Have a nice day</H5>\n";
  print "</BODY>\n";
  print "</HTML>\n";


  Once you have created the file, you need to configure PERL to run securely with Internet Information. Perl.exe should not be located in any of the directories accessible by a user with a browser.

  With a script mapping in the registry, you can place the Perl.exe outside of the normal directory structure a user has access to.

  To configure PERL script mapping

     1.Start Regedt32.exe and open the following registry key:

       HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC
\Parameters\ScriptMap

     2.Click Add Value from the Edit menu.

     3.The Value Name is .pl

     4.The Data type is REG_SZ.

     5.The String value is <the full path to perl.exe>\perl.exe %s %s

       NOTE: The "%s %s" is case sensitive. (e.g. "%S %S" will not work).

     6.Restart the WWW service.

  Now that the registry has been configured, you can test the PERL script with your browser.
  Using the defaults directory structure with IIS, the URL would be the following:

       http://<Server Name>/scripts/helloworld.pl?
0
 
LVL 2

Author Comment

by:da511
ID: 2641297
Where to find the Pearl.exe. I am not sure about this part
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2641309
perl is bundled with IIS. check for perl.exe in the directory where you have installed IIS.(dir /s/w/a/p perl.exe)
0
 
LVL 2

Author Comment

by:da511
ID: 2641374
how come I can't find it. Is it inside the Inetpub directory??
Can anyone pls help pls. I really need it to be done quickly

Thanks

Your Help will be greatly appreciated
0
 
LVL 2

Author Comment

by:da511
ID: 2641544
What about the extensiton .pm how can I add it in the registry. Pls send me the Pearl.exe at da511@singnet.com.sg
0
 
LVL 2

Author Comment

by:da511
ID: 2641553
Can you tell me where to place the pearl.exe
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2641645
"...Is it inside the Inetpub directory"

yes it should be in the Inetpub directory. try this. Lets say your inetpub is in the c drive.

* go to the DOS prompt.
* change to c:\
* at the command prompt, type dir c:\perl.exe /s/w/a/p

if perl.exe exists on your system, you will find the exact location to the file.

Let's say you dont have perl.exe on your system, you can download the same from ....

http://www.cpan.org/ports/index.html#win32

Also checkout for PERL under IIS ...
http://www.geocities.com/SiliconValley/Park/8312/perlis.htm


once you have the downloaded file, unzip it and run set up.

Then follow the steps that i had mentioned earlier.

Hope that helps. :-)
0
 
LVL 2

Author Comment

by:da511
ID: 2641773
Is it under the "module"
There are a lot of zip files with different different name. which is it
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2641824
you can get Standard Perl (5.004) for Win32 for x86 at
(http://www.cpan.org/ports/win32/Standard/x86/perl5.00402-bindist04-bc.zip)

when you unzip this file, it creates a directory (perl5.00402-bindist04-bc) under which it store all the PERL executables and modules. The perl.exe is in perl5.00402-bindist04-bc\perl\bin directory.

if you want i can email the zip file (1.5MB) to your email address.
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2641832
sorry the file size is not 1.5 MB but 5.9 MB. let me know if your still want it and i will email it to da511@singnet.com.sg


0
 
LVL 2

Author Comment

by:da511
ID: 2641883
I think I can download it myself. How about the .pm extension. Do I need to do any thing to this
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2641919
pm are PERL modules that are used when you start writing perl code.
your first target should be to download & install PERL for Win 32 and configure IIS so that it interprets perl scripts properly.

ONLY after that will you need to use a .pm (PERL Module) file like CGI.pm etc..

Rgds
0
 
LVL 2

Author Comment

by:da511
ID: 2641966
I have already found the perl.exe
Can u explain this?? I am still not sure where to place the file. Can u give me an example of where to place the file

"Once you have created the file, you need to configure PERL to run securely with Internet Information. Perl.exe should not be located in any of the directories accessible by a user with a browser."

0
 
LVL 16

Expert Comment

by:maneshr
ID: 2641997
can you pl. give me the full path to the perl.exe file??

Eg. C:\xyz\perl.exe

And also give me the full path to the Inetpub directory??
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 2

Author Comment

by:da511
ID: 2642035
For the perl.exe, I just copy it from the folder I had unzipped from and place it on the desktop at the moment
For the Inetpub, the path is D:\Inetpub
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2642286
you will have to use the entire directory and not just the perl.exe file.

so lets say you have unzipped the downloaded file in c:\perl5.00402-bindist04-bc

then the full path to your PERL executable is ...

c:\perl5.00402-bindist04-bc\perl\bin

with this info now you can use the "Configuring and Testing a PERL Script with Internet Information Server (IIS)" section that i have explained above.

Rgds
0
 
LVL 2

Author Comment

by:da511
ID: 2643271
Can you explain this in again

Is this correct
Name         Data
======================
Default      ""
..pl          D:\perl5\perl\bin\perl.exe
             %s %s  

2.Click Add Value from the Edit menu.
3.The Value Name is .pl
4.The Data type is REG_SZ.
5.The String value is <the full path to perl.exe>\perl.exe %s %s
6.Restart the WWW service.

Where to add REG_SZ Do it had a period behind this example "REG_SZ."  

Thanks
David Wong

0
 
LVL 10

Accepted Solution

by:
makerp earned 150 total points
ID: 2643925
to install/configure perl in iis do this.. its easy  

if your on winNT then download activeperl. it makes for such an easy life. http://www.activestate.com

to enable a dir to allow execute access:

all you have to do is set the directory that you want to exe in to execute rights from within the microsoft managment consolue or using pws managemnt thingie. DO NOT set that dir to write access as well, if you try mmc will warn you of security probs.
to do this select properties on the dir in question (cgi-bin if you like) and then selet execute on the directory tab. this can be at virtual dir level of a dir underneath this.


setting up perl.exe:

when you install activeperl it sets up the .pl link to the perl exe for you. if your not using activeperl or you installed active perl after iis then you need to go to mmc/default web site/ properties/home directory and then click on the configuration option. a window will appear with all of your exention mappings in. add one for .pl

extension - .pl
executaable - <DRIVE:>\<perl path>\perl.exe %s %s
method exclusions - PUT,DELETE

by doing this at the web site level these settings will stand for all virtual dirs unless you specify other wise.

if its a perl script you want to run then leave the .pl extension, put the script in the dir with exe rights and your off !!

IIS also supports the use of a perliis.dll mapping to a .plx extension. im not sure but i think this is microsofts awnser top mod_perl. dont quote me on this though as ive never had the need to use it...

because iis does the perl thing on the extension you don not need #! perl path at the beging of you script.  if you do it will be ignored ..

to run a standard .exe then the dir permissisions need to be execute

hope this is what you want ?

0
 
LVL 16

Expert Comment

by:maneshr
ID: 2644993
."Where to add REG_SZ Do it had a period behind this example "REG_SZ."


REG_SZ is a data of  type string.

the . after REG_SZ is the full stop. you should be able to select the data type when you click of the value option.


"s this correct
                   Name         Data
                   ======================
                   Default      ""
                   ..pl          D:\perl5\perl\bin\perl.exe
                                %s %s   "

should be fine as long as your perl.exe is in the path that you have mentioned above . Also the foll should be on a single line as follows..


D:\perl5\perl\bin\perl.exe  %s %s
0
 
LVL 2

Author Comment

by:da511
ID: 2645412
To : maneshr or any other expert

Can I send my webpages to you so that you can tell me what type of cgi is used. What is required to host this site on the IIS because I am not the one who actually created this webpages.
I really want to find the root of the problem

Can you experts pls help. I really need the website to be up immediately.

Pls give me your email address so that I can email the folder to you. It is just a 1.33mb zip file.

My email address is da511@singnet.com.sg


Thanks
0
 
LVL 2

Author Comment

by:da511
ID: 2645434
I think I am using cgi written in Visual basic. What are the things I need to set in IIS
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2645496
you can email me at maneshr@hotmail.com.
0
 
LVL 2

Author Comment

by:da511
ID: 2645659
maneshr, the email that I had sent to you bounce back to me. Is this a valid email address
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2645679
yes it is. try sending to
maneshr@yahoo.com with a CC to jitu7125@hotmail.com

0
 
LVL 2

Author Comment

by:da511
ID: 2646125
I think it is those exe files unable to use them
0
 
LVL 2

Author Comment

by:da511
ID: 2646147
It is those exe files in the cgi-bin that I cannot execute
0
 

Expert Comment

by:gherson
ID: 8255630
To respond to the last two comments, the way I got .exe's executing on the server, instead of offered for download, was to define my local cgi-bin dir as a virtual directory to IISv5.0 (this wasn't nec on my WinXP IISv5.1 machine).  Previous to that I had tried all the items I saw suggested, etc, to no avail so this is good to know.

Defining virtual directories is easy.  On Computer Management - Services - Internet Information Services - Your Web Site, right-click.  Click New - Virtual Directory and your about done.

0
 
LVL 10

Expert Comment

by:makerp
ID: 8263083
i should imagine people have forgotten about this Q ;)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
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)
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

13 Experts available now in Live!

Get 1:1 Help Now