RexecTest.pas 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. { $HDR$}
  2. {**********************************************************************}
  3. { Unit archived using Team Coherence }
  4. { Team Coherence is Copyright 2002 by Quality Software Components }
  5. { }
  6. { For further information / comments, visit our WEB site at }
  7. { http://www.TeamCoherence.com }
  8. {**********************************************************************}
  9. {}
  10. { $Log: 11271: RexecTest.pas
  11. {
  12. Rev 1.1 4/4/2003 7:54:06 PM BGooijen
  13. compiles again
  14. }
  15. {
  16. { Rev 1.0 11/12/2002 09:19:36 PM JPMugaas
  17. { Initial check in. Import from FTP VC.
  18. }
  19. unit RexecTest;
  20. interface
  21. uses
  22. IndyBox,
  23. Classes,
  24. IdContext,
  25. IdTCPServer,
  26. IdTCPClient;
  27. type
  28. TRexecServer = class(TIndyBox)
  29. procedure DoClient;
  30. procedure RexecCommand(AContext:TIdContext;
  31. AStdErr : TIdTCPClient; AUserName, APassword, ACommand : String);
  32. public
  33. procedure Test; override;
  34. end;
  35. implementation
  36. uses IdRexec, IdRexecServer, SysUtils;
  37. { TRexecServer }
  38. procedure TRexecServer.RexecCommand(AContext:TIdContext;
  39. AStdErr: TIdTCPClient; AUserName, APassword, ACommand: String);
  40. begin
  41. AContext.Connection.IOHandler.WriteLn('Listening Port: '+IntToStr(AStdErr.Port ));
  42. AContext.Connection.IOHandler.WriteLn('User ID: '+AUserName);
  43. AContext.Connection.IOHandler.WriteLn('Password: '+APassword);
  44. AContext.Connection.IOHandler.WriteLn('Command: '+ACommand);
  45. end;
  46. procedure TRexecServer.DoClient;
  47. begin
  48. with TIdRexec.Create(nil) do try
  49. UserName := 'TESTUSER';
  50. PassWord := 'PASSWORD';
  51. Host := '127.0.0.1';
  52. Status( Execute('TEST /f /s'));
  53. finally
  54. Free;
  55. end;
  56. end;
  57. procedure TRexecServer.Test;
  58. begin
  59. with TIdRexecServer.Create(nil) do
  60. try
  61. OnCommand := RexecCommand;
  62. Active := True;
  63. DoClient;
  64. finally
  65. Free;
  66. end;
  67. end;
  68. initialization
  69. TIndyBox.RegisterBox(TRexecServer, 'Rexec Server', 'Servers');
  70. end.