testproc.pp 603 B

1234567891011121314151617181920212223242526272829303132333435363738
  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.
  26. {
  27. $Log$
  28. Revision 1.6 2005-02-14 17:13:18 peter
  29. * truncate log
  30. }