Unfortunately, I've tried both the full path and just the name - apparently TProcess is supposed to look in the path - and it does work. When it is called, it returns a '0' indicating successful completion.
I just tried it again with /sbin/ping instead of ping and the behaviour is just the same. Is there an easier way to print the stream that comes back from TProcess? I think that the problem is in TStringList. On 21 May 2014 14:08, Mattias Gaertner <nc-gaert...@netcologne.de> wrote: > 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 _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal