IdRexecServer.pas 2.6 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: 10309: IdRexecServer.pas
  11. {
  12. { Rev 1.0 2002.11.12 10:50:36 PM czhower
  13. }
  14. unit IdRexecServer;
  15. {based on
  16. http://www.winsock.com/hypermail/winsock2/2235.html
  17. http://www.private.org.il/mini-tcpip.faq.html}
  18. { 2001, Feb 17 - J. Peter Mugaas
  19. moved much of the code into IdRemoteCMDServer so it can be
  20. reused in IdRSHServer
  21. 2001, Feb 15 - J. Peter Mugaas
  22. made methods for error and sucess command results
  23. 2001, Feb 14 - J. Peter Mugaas
  24. started this unit
  25. This is based on the IdRexec.pas unit and
  26. programming comments at http://www.abandoned.org/nemon/rexeclib.py}
  27. interface
  28. uses
  29. Classes,
  30. IdAssignedNumbers, IdRemoteCMDServer, IdTCPClient, IdTCPServer;
  31. type
  32. TIdRexecCommandEvent = procedure (AThread: TIdPeerThread;
  33. AStdError : TIdTCPClient; AUserName, APassword, ACommand : String) of object;
  34. TIdRexecServer = class(TIdRemoteCMDServer)
  35. protected
  36. FOnCommand : TIdRexecCommandEvent;
  37. procedure DoCMD(AThread: TIdPeerThread;
  38. AStdError : TIdTCPClient; AParam1, AParam2, ACommand : String); override;
  39. public
  40. constructor Create(AOwner : TComponent); override;
  41. published
  42. property OnCommand : TIdRexecCommandEvent read FOnCommand write FOnCommand;
  43. property DefaultPort default Id_PORT_exec;
  44. end;
  45. implementation
  46. { TIdRexecServer }
  47. constructor TIdRexecServer.Create(AOwner: TComponent);
  48. begin
  49. inherited;
  50. DefaultPort := Id_PORT_exec;
  51. {This variable is defined in the TIdRemoteCMDServer component. We do not
  52. use it here because Rexec does not require it. However, we have to set this to
  53. to false to disable forcing ports to be in a specific range. The variable in is the
  54. anscestor because only accepting clients in a specific range would require a change
  55. to the base component.}
  56. FForcePortsInRange := False;
  57. FStdErrorPortsInRange := False;
  58. end;
  59. procedure TIdRexecServer.DoCMD(AThread: TIdPeerThread;
  60. AStdError: TIdTCPClient; AParam1, AParam2, ACommand: String);
  61. begin
  62. if Assigned(FOnCommand) then begin
  63. FOnCommand(AThread,AStdError,AParam1,AParam2,ACommand);
  64. end;
  65. end;
  66. end.