home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscRemoteSubprocess.m -- a Obj-C wrapper around "rsh"
- // Originally written by Drew Davidson (c) 1994 by Drew Davidson.
- // Modified by Don Yacktman for inclusion into the MiscKit.
- // Version 1.0. All rights reserved.
- // This notice may not be removed from this source code.
- //
- // This object is included in the MiscKit by permission from the author
- // and its use is governed by the MiscKit license, found in the file
- // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
-
- /*----------------------------------------------------------------------------
- $Source$
-
- SYNOPSIS
- Executes a command on a remote host.
-
- REVISIONS
- $Log$
- ----------------------------------------------------------------------------*/
- #import <libc.h>
- #import <misckit/misckit.h>
-
- @implementation MiscRemoteSubprocess
-
- /*-----------------------------< CLASS METHODS >-----------------------------*/
- + (const char *)thisHost
- { static id thisHost = nil;
-
- if (!thisHost)
- { thisHost = [[MiscString alloc] initCapacity:MAXHOSTNAMELEN];
- gethostname([thisHost buffer],MAXHOSTNAMELEN);
- [thisHost fixStringLength];
- }
- return([thisHost stringValue]);
- }
-
- /*---------------------------< INIT/FREE METHODS >---------------------------*/
- - init:(const char *)aString withDelegate:theDelegate
- {
- host = [[MiscString allocFromZone:[self zone]] initStringValue:[[self class] thisHost]];
- [super init:aString withDelegate:theDelegate];
- return(self);
- }
-
- /*-----------------------------< OTHER METHODS >-----------------------------*/
- - setHost:(const char *)aString
- {
- if (![self isRunning])
- [host setStringValue:aString];
- return(self);
- }
-
- - (const char *)host
- {
- return([host stringValue]);
- }
-
- - execute:(const char *)aString onHost:(const char *)hostname
- {
- [self setHost:hostname];
- return([self execute:aString]);
- }
-
- /*--------------------------< OVERRIDDEN METHODS >---------------------------*/
- - pause:sender
- {
- return(self);
- }
-
- - resume:sender
- {
- return(self);
- }
-
- - terminate:sender
- {
- [self terminateInput];
- return([super terminate:sender]);
- }
-
- - execChild:(const char *)aString
- {
- execl("/usr/ucb/rsh", "rsh", [host stringValue], (strlen(aString) > 0) ? aString : 0, 0);
- return(self);
- }
-
- @end
-