#exec
The #exec Server-Side Include (SSI) directive runs a specified application or shell command and sends the output (standard output or ISAPI WriteClient data) to the client browser. You must surround a directive with HTML comment delimiters.
This directive can be used only in STM pages; it cannot be used in ASP pages. There is no matching ASP script method for including the output of multiple CGI scripts or ISAPI applications in a Web page.
The file containing this directive must use a file name extension that is mapped to the SSI interpreter; otherwise, the Web server will not process the directive. By default, the file name extensions .stm, .shtm, and .shtml are mapped to the SSI interpreter (ssinc.dll).
An STM page using this directive must be run by itself or by calling it from an ASP page by using Response.Redirect. Calling an STM page from an ASP page with Server.Transfer, Server.Execute, or #include will not work because that would force the STM page to go through Asp.dll instead of through Ssinc.dll.
If you have the IIS Manager installed, you can modify default extension mappings and add new mappings; . Because you cannot map a file name extension to more than one executable, you cannot use thisdirective in ASP files. ASP files are already mapped to Asp.dll and must stay that way.
The following example uses the cgi command type to run an ASP page, so there is no need to add values to your registry. It would be more efficient to use Server.Execute, Server.Transfer, or #include to run Test.asp from Exec.asp, but this example illustrates only the #exec directive in an STM file.
--- Exec.asp ---
<FORM NAME="RunExec" METHOD="POST" ACTION="Exec.asp">
<INPUT TYPE="SUBMIT" VALUE="Run the #exec Directive" NAME="RunExec">
</FORM>
<%
If Len(Request.Form("RunExec")) Then
Response.Redirect("Exec.stm")
End If
%>
--- Exec.stm ---
<H3>Inside Exec.stm</H3> <!-- #exec CGI="/testfolder/test.asp?test=Hello" --> <FORM NAME="Return" METHOD="POST" ACTION="Exec.asp"> <INPUT TYPE="SUBMIT" VALUE="Return to Previous Page" NAME="Return"> </FORM>
--- Test.asp ---
<%
Response.Write "<BR>Inside Test.asp.<BR>"
Response.Write "Test = " & Request.QueryString("Test") & ".<BR>"
%>
The following example uses the cgi command to run an ISAPI DLL named W3test.dll.
<!-- #exec CGI="/scripts/w3test.dll?SimulatePendingIO" -->
Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.
Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.
Product: IIS