On Wed, 21 May 2014 13:00:58 +0200 Peter Brooks <peter.bro...@kchclinics.com> wrote:
> 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'; TProcess needs the full path: '/bin/ping' TProcess needs to be extended to raise an exception in this case. > 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. Mattias _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal