IP*Works!

ipworks
Class Rshell

java.lang.Object
  |
  +--ipworks.Rshell

public class Rshell
extends java.lang.Object

The Rshell class is used to execute commands on a remote Unix machine using the rshell mechanism.

The Rshell class allows remote execution of commands on UNIX hosts, or any other system with the rshell interface. Using the class is very simple. The destination is specified by the RemoteHost property, the login information is given by the LocalUser and RemoteUser properties, and the command to execute by the Command property. Further input can be supplied to the command by assigning data to the Stdin property.

The output of the command is returned through the Stdout event. If an error happens on the protocol level, the error message can be found in the ErrorMessage property. Errors during command execution (the stderr stream) are given by the Stderr event.

To be able to successfully use the class, the remote host must be set up to allow execution of commands via rshell from the machine the class runs on.


Constructor Summary
Rshell()
           
 
Method Summary
 void addRshellEventListener(RshellEventListener l)
           
 void fireConnected(int statusCode, java.lang.String description)
          Fired immediately after a connection completes (or fails).
 void fireDisconnected(int statusCode, java.lang.String description)
          Fired when a connection is closed.
 void fireError(int errorCode, java.lang.String description)
          Information about errors during data delivery.
 void fireStderr(byte[] text, boolean EOL)
          Fired when data (complete lines) come in through stderr.
 void fireStdout(byte[] text, boolean EOL)
          Fired when data (complete lines) come in through stdout.
 int getBytesSent()
          The number of bytes actually sent after an assignment to Stdin.
 java.lang.String getCommand()
          The command to be sent to the remote host.
 byte[] getEOL()
          Used to break the stdout data stream into chunks separated by its value.
 byte[] getErrEOL()
          Used to break the stderr data stream into chunks separated by its value.
 java.lang.String getErrorMessage()
          The error message returned when any of the steps prior to command execution fail.
 java.lang.String getLocalHost()
          The name of the local host.
 java.lang.String getLocalUser()
          The id of the user on the local machine.
 java.lang.String getRemoteHost()
          The address of the RemoteHost.
 int getRemotePort()
          The remote shell service port (default is 514).
 java.lang.String getRemoteUser()
          The id of the user on the remote host.
 void removeRshellEventListener(RshellEventListener l)
           
 void setCommand(java.lang.String command)
          The command to be sent to the remote host.
 void setEOL(byte[] EOL)
          Used to break the stdout data stream into chunks separated by its value.
 void setErrEOL(byte[] errEOL)
          Used to break the stderr data stream into chunks separated by its value.
 void setLocalUser(java.lang.String localUser)
          The id of the user on the local machine.
 void setRemoteHost(java.lang.String remoteHost)
          The address of the RemoteHost.
 void setRemotePort(int remotePort)
          The remote shell service port (default is 514).
 void setRemoteUser(java.lang.String remoteUser)
          The id of the user on the remote host.
 void setStdin(byte[] stdin)
          A string of data to be sent to the remote host while connected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rshell

public Rshell()
Method Detail

getBytesSent

public int getBytesSent()
The number of bytes actually sent after an assignment to Stdin. The BytesSent property shows how many bytes were sent after the last assignment to Stdin . Please check the Stdin property for more information.


getCommand

public java.lang.String getCommand()
The command to be sent to the remote host. Assigning a UNIX command to this property makes the class attempt to connect to the RemoteHost and execute the command using the rshell protocol. There is no need to append an end-of-line character to the command.

If "" (empty string) is assigned to the Command property, the current connection is broken.


setCommand

public void setCommand(java.lang.String command)
                throws IPWorksException
The command to be sent to the remote host. Assigning a UNIX command to this property makes the class attempt to connect to the RemoteHost and execute the command using the rshell protocol. There is no need to append an end-of-line character to the command.

If "" (empty string) is assigned to the Command property, the current connection is broken.


getEOL

public byte[] getEOL()
Used to break the stdout data stream into chunks separated by its value. The EOL property is used to define boundaries in the Stdout stream using the value of the property.


setEOL

public void setEOL(byte[] EOL)
            throws IPWorksException
Used to break the stdout data stream into chunks separated by its value. The EOL property is used to define boundaries in the Stdout stream using the value of the property.


getErrEOL

public byte[] getErrEOL()
Used to break the stderr data stream into chunks separated by its value. The ErrEOL property is used to define boundaries in the Stderr stream using the value of the property.


setErrEOL

public void setErrEOL(byte[] errEOL)
               throws IPWorksException
Used to break the stderr data stream into chunks separated by its value. The ErrEOL property is used to define boundaries in the Stderr stream using the value of the property.


getErrorMessage

public java.lang.String getErrorMessage()
The error message returned when any of the steps prior to command execution fail. This error message is returned on a separate connection associated with error messages.


getLocalHost

public java.lang.String getLocalHost()
The name of the local host. When connected, the IP address of the interface through which the connection was made. The LocalHost property contains the name of the local host as obtained by the gethostname() Winsock call.

If the class is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).


getLocalUser

public java.lang.String getLocalUser()
The id of the user on the local machine. This must be the id of a user in the local host for whom remote execution of commands is permitted in the remote host.


setLocalUser

public void setLocalUser(java.lang.String localUser)
                  throws IPWorksException
The id of the user on the local machine. This must be the id of a user in the local host for whom remote execution of commands is permitted in the remote host.


getRemoteHost

public java.lang.String getRemoteHost()
The address of the RemoteHost. Domain names are resolved to IP addresses. The RemoteHost property specifies the IP address (IP number in dotted internet format) or Domain Name of the remote host. It is set before a connection is attempted and cannot be changed once a connection is in progress.

If the RemoteHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the RemoteHost property is set to the corresponding address. If the search is not successful, an error is returned.


setRemoteHost

public void setRemoteHost(java.lang.String remoteHost)
                   throws IPWorksException
The address of the RemoteHost. Domain names are resolved to IP addresses. The RemoteHost property specifies the IP address (IP number in dotted internet format) or Domain Name of the remote host. It is set before a connection is attempted and cannot be changed once a connection is in progress.

If the RemoteHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the RemoteHost property is set to the corresponding address. If the search is not successful, an error is returned.


getRemotePort

public int getRemotePort()
The remote shell service port (default is 514). The RemotePort property specifies the rshell service port on the remote host.

A valid port number (a value between 1 and 65535) is required for the connection to take place. The property must be set before command execution is attempted.


setRemotePort

public void setRemotePort(int remotePort)
                   throws IPWorksException
The remote shell service port (default is 514). The RemotePort property specifies the rshell service port on the remote host.

A valid port number (a value between 1 and 65535) is required for the connection to take place. The property must be set before command execution is attempted.


getRemoteUser

public java.lang.String getRemoteUser()
The id of the user on the remote host. This must be the id of a user in the remote host for whom remote execution of commands is permitted.


setRemoteUser

public void setRemoteUser(java.lang.String remoteUser)
                   throws IPWorksException
The id of the user on the remote host. This must be the id of a user in the remote host for whom remote execution of commands is permitted.


setStdin

public void setStdin(byte[] stdin)
              throws IPWorksException
A string of data to be sent to the remote host while connected. This property is used to provide input for the process in the remote host.

If you are sending data to the remote host faster than it can process it, or faster than the network bandwidth allows, the outgoing queue might fill up. When this happens, Stdin


fireConnected

public void fireConnected(int statusCode,
                          java.lang.String description)
Fired immediately after a connection completes (or fails). (Called internally to dispatch the event.)
See Also:
RshellConnectedEvent

fireDisconnected

public void fireDisconnected(int statusCode,
                             java.lang.String description)
Fired when a connection is closed. (Called internally to dispatch the event.)
See Also:
RshellDisconnectedEvent

fireError

public void fireError(int errorCode,
                      java.lang.String description)
Information about errors during data delivery. (Called internally to dispatch the event.)
See Also:
RshellErrorEvent

fireStderr

public void fireStderr(byte[] text,
                       boolean EOL)
Fired when data (complete lines) come in through stderr. (Called internally to dispatch the event.)
See Also:
RshellStderrEvent

fireStdout

public void fireStdout(byte[] text,
                       boolean EOL)
Fired when data (complete lines) come in through stdout. (Called internally to dispatch the event.)
See Also:
RshellStdoutEvent

addRshellEventListener

public void addRshellEventListener(RshellEventListener l)
                            throws java.util.TooManyListenersException

removeRshellEventListener

public void removeRshellEventListener(RshellEventListener l)

IP*Works!

Copyright (c) 1995-2000 by /n software inc. - All rights reserved.