testproc.pp 782 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.5 2002-09-07 15:15:28 peter
  29. * old logs removed and tabs fixed
  30. Revision 1.4 2002/05/31 11:33:49 marco
  31. * 1.0.x renamefest
  32. Revision 1.3 2002/05/18 13:38:30 michael
  33. + Fixed test program to new interface
  34. }