09-14-2019, 11:50 AM
(This post was last modified: 09-14-2019, 11:55 AM by cprmlao@hotmail.com.)
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:
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?
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;