I'm cross posting my earlier post in my MSDN blog just to let you know how interoperable IIS 7.0 is.
I was working for one of our customer who wanted to host his POSIX executables over IIS 7.0 on Windows Vista. He has .dat files which were built on an UNIX environment. He wanted use them as a CGI application hosted on IIS 7.0. Here is where the power of inter-operability of Windows comes into play. Check out the below article to know more on the Inter-Operability piece of Windows - "Subsystem for UNIX-based Applications"
Now, to execute the .dat files created from an UNIX environment, I need to add the "Subsystem for UNIX-based Applications" on my Vista. It is present as an optional windows components which you can add by the below steps:
- Go to run prompt (Windows Key + R) and type appwiz.cpl
- Click on Turn Windows features on or off
- Check "Subsystem for UNIX-based Applications" and click on OK
Now, the interesting piece - How to execute the executable which would generate a HTML output like below:
Open a command prompt and run the posix.exe which will be found in C:\WINDOWS (%WinDir%). That should give you an output similar to below:
So, we need to supply arguments to the posix.exe. Below is an example of executing hello.dat with posix.exe.
Now, comes a question, how to do the same with IIS 7.0? IIS 7.0 is a very powerful web server and it supports CGI applications too. Below is how you would add a Script Map for the .dat files which should be executed on the posix.exe with the argument lists.
1. Add Script Map for .dat files
a. Select the Website and in Features View double click on Handler Mappings
b. In the right hand side Actions Pane, select “Add Script Map”
c. Put *.dat as the Request Path (replace .dat with the executable extension)
d. Put “C:\Windows\posix.exe /c “%s””
e. Give a name for the Script Map and click on OK
Now, browse the file which would be supplied as a parameter to the posix.exe and would generate the output needed.
So, here we achieved hosting a POSIX executable created in a UNIX environment, and running on Windows Vista, also hosted on web via IIS 7.0. Isn't this a beauty? Truly, it is!
You can use FastCGI module to achieve greater results of CGI hosting with IIS7.