jimac has asked for the wisdom of the Perl Monks concerning the following question:

I want to #exec some perl cgi code in some SSI under IIS.

I have the server correctly configured and I place the following in the .shtml file:

<!--#exec cgi="/cgi-bin/mycode.pl"-->

The page just hangs at that point, regardless of what is in mycode.pl.

IIS expects the cgi code to send HSE_STATUS_PENDING at the end of the code to signal completion.

Anyone know how to do this?

Jim.

Replies are listed 'Best First'.
Re: #exec in SSI
by virtualsue (Vicar) on May 08, 2002 at 11:01 UTC
    Have you tried renaming your script 'mycode.cgi'? Some servers insist on the 'cgi' extension in SSI.
      No, the server is configured to associate the .pl extension to perl.

      The IIS 5.1 documentation says that a #exec'd CGI program must send HSE_STATUS_PENDING when it terminates or the server will hang indefinitely.

      This is what is happening. I just don't know how to send HSE_STATUS_PENDING.....

      Jim.

        I've just had a look at the IIS 5.1 documentation on MSDN, and your interpretation of what is required isn't the same as what I've just read.

        http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iisref/html/psdk/asp/serv9i5h.asp

        Specifically:

        The SSI interpreter (Ssinc.dll) will wait indefinitely for applications returning HSE_STATUS_PENDING unless the ServerSupportFunction is called to finish the session.

        So I don't think you want to return HSE_STATUS_PENDING. If you did, another site indicated that the correct value for this is 3. HSE_STATUS_SUCCESS is 1. Your problem sounds like a configuration issue to me, but I do not work with IIS so I really don't know. I've used SSI exec with Apache and never had any problems.

        Not that I know much about web servers, etc., but a Google search led me to think that HSE_STATUS_PENDING is a response associated with ISAPI, rather than CGI.

        You've probably looked at all this, but IIS configs for scripts as CGI vs scripts for ISAPI seem to be addressed at various places:

        Could it be that an additional or corrected IIS config would bypass the need to programmatically send this flag?

Re: #exec in SSI
by Dog and Pony (Priest) on May 08, 2002 at 09:52 UTC
    You probably should never use exec to include any other file. I don't know about IIS, but unless it is b0rked (*gasp* not IIS!), it should have something like this to use instead:
    <!--#include virtual="/cgi-bin/mycode.pl" -->

    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.
      But I'm not trying to include it, I'm trying to execute it!

      #include won't execute the file.....

      Jim.

        The virtual directive is intended to be the smart way to include information into a page. Whether its a page or a program you are still attempting to 'include' its output into your page. The advantage to using virtual is that you can use files or programs without having to change the whole of your include statement.

        Its also a little securer.

        Now I know apache supports both and so does IIS, but as to whether you can include CGI apps in a 'shtml' page on IIS - well thats one to look to MS about.
        #include executes the file and then includes the output. I've used it that way many times.

        John
Re: #exec in SSI
by dws (Chancellor) on May 08, 2002 at 16:43 UTC
    IIS expects the cgi code to send HSE_STATUS_PENDING at the end of the code to signal completion.

    Look that symbol up. I'll bet it is zero (0).

    I've used SSI on IIS many times, and a simple   exit(0); at the end of the script has sufficed.

    I haven't been able to track down the source, so this may be superstition, but I've heard that any scripts you execute this way must be in virtual directories, and those directories must be configured to allow script execution. This is all I ever do, and I've had no problems.

Re: #exec in SSI
by P0w3rK!d (Pilgrim) on May 08, 2002 at 19:24 UTC
    Jim, Do not use exec...like ever. Also, make sure the IIS server is confiured correctly to handle the .pl extension. Finally, you probably can set the HSE_STATUS_PENDING and exit() out, thus handling the IIS expectations. -P0w3rK!d