Freigeben über


HOW TO host a POSIX executable on IIS 7.0?

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"

https://technet2.microsoft.com/windowsserver/en/library/695ac415-d314-45df-b464-4c80ddc2b3bc1033.mspx?mfr=true

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:

  1. Go to run prompt (Windows Key + R) and type appwiz.cpl
  2. Click on Turn Windows features on or off
  3. 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:

 <HTML>
  <Title> Sample Program </Title>
  <Body> 
   <H1> Hello World! </H1>
  </Body>
 </HTML>

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:

 posix: command missing
 usage: posix [/u] /c <path> [<args>]

So, we need to supply arguments to the posix.exe. Below is an example of executing hello.dat with posix.exe.

 posix /c hello.dat

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

image

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!

Happy Learning!

Comments

  • Anonymous
    September 25, 2007
    PingBack from http://www.artofbam.com/wordpress/?p=2889

  • Anonymous
    October 05, 2007
    Wow.. that's a great post. It is interesting to see IIS7 delivering such an interoperability. Good job. Thanks for sharing. Robert

  • Anonymous
    February 24, 2008
    Mike Volodarsky, Program Manager of the IIS team has a nice link to share - a survey by InformationWeek

  • Anonymous
    February 24, 2008
    Mike Volodarsky , Program Manager of the IIS team has a nice link to share - a survey by InformationWeek