[fpc-pascal] Ping problems - OS/X

Peter Brooks peter.brooks at kchclinics.com
Wed May 21 13:00:58 CEST 2014


Sorry, I misled you. I did move it higher up, earlier, to test
something, and I forgot to put it back.

This version has exactly the same behaviour:

-rw-r--r--  1 peterbrooks  wheel       0 21 May 13:00 output.txt

Program nmp(input,output);

uses
  Classes, SysUtils,  Process;
var
  AProcess: TProcess;
  AStringList: TStringList;
  n :Integer;
begin { main }
  for n := 0 to 20 do
begin { for }
  AStringList := TStringList.Create;
  AProcess := TProcess.Create(nil);
  AProcess.Executable := 'ping';
  AProcess.Parameters.Add('-c 1');
  AProcess.Parameters.Add('www.freepascal.org');
  AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
  AProcess.Execute;
  Writeln(n,' Execution Over: Exit Status: ',AProcess.ExitStatus);
  AStringList.Add('stdout:');
  AStringList.LoadFromStream(Aprocess.Output);
  AStringList.Add('stderr:');
  AStringList.LoadFromStream(AProcess.Stderr);
  AStringList.LoadFromStream(AProcess.Output);
  AStringList.SaveToFile('output.txt');
  writeln(AStringList.Text);
AstringList.Free;
AProcess.Free;
end; {for}
close(output);
close(input);
end.



More information about the fpc-pascal mailing list