testproc.pp 524 B

12345678910111213141516171819202122232425262728293031
  1. program testproc;
  2. uses classes,process;
  3. Const BufSize = 1024;
  4. {$ifdef unix}
  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(Nil);
  14. S.Commandline:=theprogram;
  15. S.Options:=[poUsePipes,poNoConsole];
  16. S.execute;
  17. Repeat
  18. Count:=s.output.read(buf,BufSize);
  19. // reverse print for fun.
  20. For I:=Count downto 1 do
  21. write(buf[i]);
  22. until Count=0;
  23. writeln;
  24. S.Free;
  25. end.