Atozed Forums
IWCGIRunner not working with simple .bat cgi - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: IWCGIRunner not working with simple .bat cgi (/thread-1240.html)



IWCGIRunner not working with simple .bat cgi - cprmlao@hotmail.com - 09-14-2019

Hi, Alexandre,

I am fighting with IWCGIRunner and until now it is the winner.
I created a simple  "test.bat"  and I have used a  click sync of a iwbutton(IWBTNACAO) . The test.bat file has  this content:

Code:
@echo off echo Content-type: text/plain echo. echo. echo Hi ! echo Your IP ADDRESS is %REMOTE_ADDR% and your BROWSER is %HTTP_USER_AGENT%"


First problem: IWCGIRunner is returning nothing. 
Second problem: When sending a response to browser with WriteString I get an AV of "replytype already set"

Please, what is wrong?


Code:
procedure TF_MyForm.IWBTNACAOClick(Sender: TObject);
begin
var
  CGIRunner: TIWCGIRunner;
  CGIModuleName: string;
  s: string;
begin
  CGIModuleName := TIWAppInfo.GetAppPath + 'wwwroot\cgi-bin\test.bat';
  CGIRunner := TIWCGIRunner.Create;
  try
    // Set the name of the CGI module which runs our report
    CGIRunner.CGIModule := CGIModuleName;
    CGIRunner.Execute(WebApplication, WebApplication.Request);
    // Check status result. Zero indicates success. Anything else is an error
    if CGIRunner.StatusResult = 0 then
    begin
      s:=CGIRunner.ResponseContent.Text;
      //Problem here: CGIRunner.ResponseContent.Text is empty
      with WebApplication.Response do
        begin
        ResetReplyType;
        Code := 200;
        ContentType := MIME_HTML;
        WriteString(s); //Problem here: Here I get an AV about ReplyType already set
        end
    end else
    begin
      WebApplication.ShowMessage('Error on test.bat: ' + CGIRunner.ErrorMessage);
    end;
  finally
    CGIRunner.Free;
  end;
end;
end;



RE: IWCGIRunner not working with simple .bat cgi - Alexandre Machado - 10-24-2019

I think this has been clarified in another thread