home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / MiscKit1.2.6 / Source / MiscRemoteSubprocess.m < prev    next >
Encoding:
Text File  |  1994-03-03  |  2.2 KB  |  91 lines

  1. //
  2. //    MiscRemoteSubprocess.m -- a Obj-C wrapper around "rsh"
  3. //        Originally written by Drew Davidson (c) 1994 by Drew Davidson.
  4. //        Modified by Don Yacktman for inclusion into the MiscKit.
  5. //                Version 1.0.  All rights reserved.
  6. //        This notice may not be removed from this source code.
  7. //
  8. //    This object is included in the MiscKit by permission from the author
  9. //    and its use is governed by the MiscKit license, found in the file
  10. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  11. //    for a list of all applicable permissions and restrictions.
  12. //    
  13.  
  14. /*----------------------------------------------------------------------------
  15.     $Source$
  16.  
  17.     SYNOPSIS
  18.         Executes a command on a remote host.
  19.  
  20.     REVISIONS
  21.     $Log$
  22. ----------------------------------------------------------------------------*/
  23. #import <libc.h>
  24. #import <misckit/misckit.h>
  25.  
  26. @implementation MiscRemoteSubprocess
  27.  
  28. /*-----------------------------< CLASS METHODS >-----------------------------*/
  29. + (const char *)thisHost
  30. {    static id    thisHost = nil;
  31.  
  32.     if (!thisHost)
  33.     {    thisHost = [[MiscString alloc] initCapacity:MAXHOSTNAMELEN];
  34.         gethostname([thisHost buffer],MAXHOSTNAMELEN);
  35.         [thisHost fixStringLength];
  36.     }
  37.     return([thisHost stringValue]);
  38. }
  39.  
  40. /*---------------------------< INIT/FREE METHODS >---------------------------*/
  41. - init:(const char *)aString withDelegate:theDelegate
  42. {
  43.     host = [[MiscString allocFromZone:[self zone]] initStringValue:[[self class] thisHost]];
  44.     [super init:aString withDelegate:theDelegate];
  45.     return(self);
  46. }
  47.  
  48. /*-----------------------------< OTHER METHODS >-----------------------------*/
  49. - setHost:(const char *)aString
  50. {
  51.     if (![self isRunning])
  52.         [host setStringValue:aString];
  53.     return(self);
  54. }
  55.  
  56. - (const char *)host
  57. {
  58.     return([host stringValue]);
  59. }
  60.  
  61. - execute:(const char *)aString onHost:(const char *)hostname
  62. {
  63.     [self setHost:hostname];
  64.     return([self execute:aString]);
  65. }
  66.  
  67. /*--------------------------< OVERRIDDEN METHODS >---------------------------*/
  68. - pause:sender
  69. {
  70.     return(self);
  71. }
  72.  
  73. - resume:sender
  74. {
  75.     return(self);
  76. }
  77.  
  78. - terminate:sender
  79. {
  80.     [self terminateInput];
  81.     return([super terminate:sender]);
  82. }
  83.  
  84. - execChild:(const char *)aString
  85. {
  86.     execl("/usr/ucb/rsh", "rsh", [host stringValue], (strlen(aString) > 0) ? aString : 0, 0);
  87.     return(self);
  88. }
  89.  
  90. @end
  91.