Previous Next

Thread: Unable to run CGI executable written in C++ in IIS7.0

Last post 09-03-2008 3:39 AM by neha.noma. 8 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (9 items)

Sort Posts:

  • 07-30-2008, 1:39 AM

    Unable to run CGI executable written in C++ in IIS7.0

     Hi,

    I have CGI executable written in C++ and I have followed the steps given at http://community.activestate.com/forum-topic/configuring-perl-on-iis-7#comment-1022 to make the  CGI setup ready. My perl scripts run fine with this minimal setup. However I am still not able to run the CGI executable.

     

    I get following error in IIS 7.0 browser:

    HTTP Error 502.2 - Bad Gateway
    The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "Unrecognized character \x90 in column 3 at C:\inetpub\wwwroot\cgi-bin\CDTexample.cgi line 1. ".

     

    Detailed:

    Module CgiModule
    Notification ExecuteRequestHandler
    Handler CGI Script map
    Error Code 0x00000009
    Requested URL http://localhost:80/cgi-bin/CDTexample.cgi?atag=tag1&somedata=abc&ButtonCreate.x=24&ButtonCreate.y=22
    Physical Path C:\inetpub\wwwroot\cgi-bin\CDTexample.cgi
    Logon Method Anonymous
    Logon User Anonymous

     

    Even if I try to run from command line, I get same kind of error.

    $perl -c CDTexample.cgi
    Unrecognized character \x90 in column 3 at CDTexample.cgi line 1.

     

    Code Snippet:

    int main(void)
    {
    Report_Error("Neha ---My call successful.",0);
    return 0;
    }

    static void Report_Error(const char* Error, int detail)
    {

    Supply_Headers();
    printf("<HEAD>\r\n<TITLE>%s</TITLE></HEAD>\r\n<BODY>\r\n",Error);
    printf("<br><font color=\"#FF0000\">%s</font><br>",Error);
    if(detail !=0)
    {
        printf(" %d",detail);
    }
    printf("</BODY>\r\n</HTML>");

    }

    static void Supply_Headers()
    {
    printf("Content-Type:text/html\r\n");
    printf("\r\n");
    printf("<HTML>\r\n");
    }

     

    I am new to IIS and CGI scripts. Please guide. 


     

  • 08-01-2008, 1:24 AM In reply to

    • ksingla
    • Top 10 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 561

    Re: Unable to run CGI executable written in C++ in IIS7.0

    This doesn't seem right. Why are you trying to execute C++ code using perl.exe? Can you paste your handler configuration for .cgi? You can use command like following.

    %windir%\system32\inetsrv\appcmd list config /section:handlers | findstr /i cgi

    Thanks,
    Kj

  • 08-01-2008, 1:06 PM In reply to

    Re: Unable to run CGI executable written in C++ in IIS7.0

    You are right. I was trying to execute C CGI with perl. As I was new so was thinking that all CGI needs to be excuted with Perl.

    I just needed to add the executable path to "ISAPI and CGI restriction "list and then added CGI Module handler for *.cgi extensions. AND IT WORKED!!
     

  • 08-26-2008, 4:58 PM In reply to

    Re: Unable to run CGI executable written in C++ in IIS7.0

    Hi 

    I have the similar problem 

    my .exe downloading instread of runing on the server

    our exe program writen in  c++ which comunicate with the backend. I succeed with the IIS5 and IIS6.  IIS7  I couldn't make it work. I activate the window feture for cgi isapi  restriction

    select my exe allow it. handler mapping select allow the cgi.exe

    please help

     

     

     

  • 08-26-2008, 5:14 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 10:13 PM
    • Redmond, WA
    • Posts 1,223

    Re: Unable to run CGI executable written in C++ in IIS7.0

    Go to "handler mappings", click on "Edit Feature Permissions" and check the "Execute" check box.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 08-26-2008, 5:29 PM In reply to

    Re: Unable to run CGI executable written in C++ in IIS7.0

    you mean edit handler Permissions  Feature view   execute  check  box already check.

    let me if not the same

  • 08-27-2008, 12:48 PM In reply to

    Re: Unable to run CGI executable written in C++ in IIS7.0

    any one can help ?
  • 08-29-2008, 4:32 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 10:13 PM
    • Redmond, WA
    • Posts 1,223

    Re: Unable to run CGI executable written in C++ in IIS7.0

    Have you installed the CGI feature from "Control Panel" -> "Program and Features" -> "Windows features"?  Does the CGI-exe mapping appear in the handler mapping for your application/vdir?

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 09-03-2008, 3:39 AM In reply to

    Re: Unable to run CGI executable written in C++ in IIS7.0

    I followed below steps and it worked. Not sure whether you tried the same way or not...
    And I assume you are trying to run executable CGI.

    Set CGI execution environment
    A) Add Your.cgi to "ISAPI and CGI Restrictions" list at server level. Go to IIS Manager -> Machine -> Feature View -> Open "ISAPI and CGI Restrictions" Action pane -> Add
    Specify our Your.cgi path here and check the "Allow extension path to execute" Click OK.

    B) Add handler mapping for Your.cgi at site/server level.
    Go to Site/Server -> Feature View -> Action pane -> Add Module Mapping
    Request Path: Your.cgi
    Module: CgiModule
    Name: Test CGI handler
    Click OK.

    Hope it will help..
Page 1 of 1 (9 items)
Page view counter