testproc.pp 503 B

12345678910111213141516171819202122232425262728
  1. program testproc;
  2. uses classes,process;
  3. Const BufSize = 1024;
  4. {$ifdef linux}
  5. TheProgram = 'doecho';
  6. {$else}
  7. TheProgram = 'doecho.exe';
  8. {$endif}
  9. Var S : TProcess;
  10. Buf : Array[1..BUFSIZE] of char;
  11. I,Count : longint;
  12. begin
  13. S:=TProcess.Create(theprogram,[poExecuteOnCreate,poUsePipes,poNoConsole]);
  14. Repeat
  15. Count:=s.output.read(buf,BufSize);
  16. // reverse print for fun.
  17. For I:=Count downto 1 do
  18. write(buf[i]);
  19. until Count=0;
  20. writeln;
  21. S.Free;
  22. end.