|
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--ipworks.Rexec
The Rexec control is used to execute commands on a remote UNIX machine using the rexec mechanism.
The Rexec control allows remote execution of commands on UNIX hosts,
or any other system with the rexec interface. Using the control
is very simple. The destination is specified by the RemoteHost property, the login information is given by the RemoteUser and RemotePassword properties. Then call the Execute method with the Command to execute as a parameter. You can also set the Command property to the command that you would like to execute for identical
results. Further input can be supplied to the command by assigning data
to the Text parameter of the Send method, or via 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 control, the remote host must be set up to allow execution of commands via rexec from the machine the control runs on.
| Field Summary | |
static int |
fwNone
|
static int |
fwSOCKS4
|
static int |
fwSOCKS5
|
static int |
fwTunnel
|
| Constructor Summary | |
Rexec()
|
|
| Method Summary | |
void |
addRexecEventListener(RexecEventListener l)
|
void |
disconnect()
Disconnect from the RemoteHost . |
void |
execute(java.lang.String command)
Execute a Command on the remote host. |
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. |
byte[] |
getFirewallData()
Used to send other data to firewall. |
java.lang.String |
getFirewallHost()
Name or IP address of firewall (optional). |
java.lang.String |
getFirewallPassword()
A password if authentication is to be used connecting through the firewall. |
int |
getFirewallPort()
Port of the firewall to connect to. |
int |
getFirewallType()
Determines the type of firewall to connect through. |
java.lang.String |
getFirewallUser()
A user name if authentication is to be used connecting through a firewall. |
java.lang.String |
getLocalHost()
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
int |
getLocalPort()
The TCP port in the local host where the component binds. |
int |
getMaxLineLength()
The maximum amount of data to accumulate when no EOL is found. |
java.lang.String |
getRemoteHost()
The address of the remote host. |
java.lang.String |
getRemotePassword()
The password of the user on the remote host. |
int |
getRemotePort()
The remote exec service port (default is 512). |
java.lang.String |
getRemoteUser()
The id of the user on the remote host. |
int |
getStderrPort()
The local port where the remote systems sends the stderr stream. |
int |
getTimeout()
A timeout for the component. |
boolean |
isConnected()
Shows whether the component is connected. |
boolean |
isEnableStderr()
Enables or disables secondary (stderr) stream. |
void |
removeRexecEventListener(RexecEventListener l)
|
void |
send(byte[] text)
Send standard input to the program executing on the remote host. |
void |
setCommand(java.lang.String command)
The command to be sent to the remote host. |
void |
setEnableStderr(boolean enableStderr)
Enables or disables secondary (stderr) stream. |
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 |
setFirewallData(byte[] firewallData)
Used to send other data to firewall. |
void |
setFirewallHost(java.lang.String firewallHost)
Name or IP address of firewall (optional). |
void |
setFirewallPassword(java.lang.String firewallPassword)
A password if authentication is to be used connecting through the firewall. |
void |
setFirewallPort(int firewallPort)
Port of the firewall to connect to. |
void |
setFirewallType(int firewallType)
Determines the type of firewall to connect through. |
void |
setFirewallUser(java.lang.String firewallUser)
A user name if authentication is to be used connecting through a firewall. |
void |
setLocalHost(java.lang.String localHost)
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
void |
setLocalPort(int localPort)
The TCP port in the local host where the component binds. |
void |
setMaxLineLength(int maxLineLength)
The maximum amount of data to accumulate when no EOL is found. |
void |
setRemoteHost(java.lang.String remoteHost)
The address of the remote host. |
void |
setRemotePassword(java.lang.String remotePassword)
The password of the user on the remote host. |
void |
setRemotePort(int remotePort)
The remote exec service port (default is 512). |
void |
setRemoteUser(java.lang.String remoteUser)
The id of the user on the remote host. |
void |
setStderrPort(int stderrPort)
The local port where the remote systems sends the stderr stream. |
void |
setStdin(byte[] stdin)
A string of data to be sent to the remote host while connected. |
void |
setTimeout(int timeout)
A timeout for the component. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int fwNone
public static final int fwTunnel
public static final int fwSOCKS4
public static final int fwSOCKS5
| Constructor Detail |
public Rexec()
| Method Detail |
public int getBytesSent()
BytesSent property shows how many bytes were sent after the last
assignment to Stdin . Please check the Stdin property for more
information.
public java.lang.String getCommand()
RemoteHost and execute
the command using the rexec 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.
public void setCommand(java.lang.String command)
throws IPWorksException
RemoteHost and execute
the command using the rexec 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.
public boolean isConnected()
public boolean isEnableStderr()
EnableStderr off. Any stderr output will then be provided through
stdout.
public void setEnableStderr(boolean enableStderr)
throws IPWorksException
EnableStderr off. Any stderr output will then be provided through
stdout.
public byte[] getEOL()
EOL property is used to define boundaries in the Stdout
stream using the value of the property.
public void setEOL(byte[] EOL)
throws IPWorksException
EOL property is used to define boundaries in the Stdout
stream using the value of the property.
public byte[] getErrEOL()
ErrEOL property is used to define boundaries in the Stderr
stream using the value of the property.
public void setErrEOL(byte[] errEOL)
throws IPWorksException
ErrEOL property is used to define boundaries in the Stderr
stream using the value of the property.
public java.lang.String getErrorMessage()
public byte[] getFirewallData()
public void setFirewallData(byte[] firewallData)
throws IPWorksException
public java.lang.String getFirewallHost()
FirewallHost is given, requested connections will be
authenticated through the specified firewall when connecting.
If the FirewallHost property is set to a Domain Name, a DNS request
is initiated and upon successful termination of the request, the FirewallHost property is set to the corresponding address. If the
search is not successful, an error is returned.
public void setFirewallHost(java.lang.String firewallHost)
throws IPWorksException
FirewallHost is given, requested connections will be
authenticated through the specified firewall when connecting.
If the FirewallHost property is set to a Domain Name, a DNS request
is initiated and upon successful termination of the request, the FirewallHost property is set to the corresponding address. If the
search is not successful, an error is returned.
public java.lang.String getFirewallPassword()
FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate
to the given firewall. If the authentication fails, a trappable error is fired.
public void setFirewallPassword(java.lang.String firewallPassword)
throws IPWorksException
FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate
to the given firewall. If the authentication fails, a trappable error is fired.
public int getFirewallPort()
FirewallHost . See the
description of the FirewallHost property for
details.
Note that the FirewallPort is set automatically
when FirewallType is set to a valid value. See the
description of the FirewallType property for
details.
public void setFirewallPort(int firewallPort)
throws IPWorksException
FirewallHost . See the
description of the FirewallHost property for
details.
Note that the FirewallPort is set automatically
when FirewallType is set to a valid value. See the
description of the FirewallType property for
details.
public int getFirewallType()
FirewallPort is set to 80.
FirewallPort is set to 1080.
FirewallPort is set to 1080.
public void setFirewallType(int firewallType)
throws IPWorksException
FirewallPort is set to 80.
FirewallPort is set to 1080.
FirewallPort is set to 1080.
public java.lang.String getFirewallUser()
FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate
to the given firewall. If the authentication fails, a trappable error is fired.
public void setFirewallUser(java.lang.String firewallUser)
throws IPWorksException
FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate
to the given firewall. If the authentication fails, a trappable error is fired.
public java.lang.String getLocalHost()
LocalHost property contains the name of the local host
as obtained by the gethostname() Winsock call, or if the
user has assigned an IP address, the value of that address.
In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the control initiate connections (or accept in the case of server controls) only through that interface.
If the control 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).
NOTE: LocalHost is not persistent. You must always set it in
code, and never in the property window.
public void setLocalHost(java.lang.String localHost)
throws IPWorksException
LocalHost property contains the name of the local host
as obtained by the gethostname() Winsock call, or if the
user has assigned an IP address, the value of that address.
In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the control initiate connections (or accept in the case of server controls) only through that interface.
If the control 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).
NOTE: LocalHost is not persistent. You must always set it in
code, and never in the property window.
public int getLocalPort()
LocalPort property must be set before a connection is
attempted. It instructs the control to bind to a specific
port (or communication endpoint) in the local machine.
Setting it to 0 (default) enables the control to choose a port
at random. The chosen port will be shown by the LocalPort property after the connection is established.
LocalPort cannot be changed once a connection is made.
Any attempt to set the LocalPort property when a connection
is active will generate an error.
USe this property with caution. If you supply a value,
it must be an available port on the system, or an error will be
returned. Furthermore, the control always attempts to bind to
a secure (sub 1000) port when the value of LocalPort is the
default (0). If you supply your own value, make sure the remote
system is configured to allow that particular value.
public void setLocalPort(int localPort)
throws IPWorksException
LocalPort property must be set before a connection is
attempted. It instructs the control to bind to a specific
port (or communication endpoint) in the local machine.
Setting it to 0 (default) enables the control to choose a port
at random. The chosen port will be shown by the LocalPort property after the connection is established.
LocalPort cannot be changed once a connection is made.
Any attempt to set the LocalPort property when a connection
is active will generate an error.
USe this property with caution. If you supply a value,
it must be an available port on the system, or an error will be
returned. Furthermore, the control always attempts to bind to
a secure (sub 1000) port when the value of LocalPort is the
default (0). If you supply your own value, make sure the remote
system is configured to allow that particular value.
public int getMaxLineLength()
MaxLineLength is the size of an internal buffer, which holds
received data while waiting for an EOL string.
If an EOL string is found in the input stream before MaxLineLength characters are received, the DataIn event is
fired with the EOL parameter set to True, and the buffer is reset.
If no EOL is found, and MaxLineLength characters are accumulated
in the buffer, the DataIn event is fired with the EOL parameter
set to False, and the buffer is reset.
The minimum value for MaxLineLength is 256.
public void setMaxLineLength(int maxLineLength)
throws IPWorksException
MaxLineLength is the size of an internal buffer, which holds
received data while waiting for an EOL string.
If an EOL string is found in the input stream before MaxLineLength characters are received, the DataIn event is
fired with the EOL parameter set to True, and the buffer is reset.
If no EOL is found, and MaxLineLength characters are accumulated
in the buffer, the DataIn event is fired with the EOL parameter
set to False, and the buffer is reset.
The minimum value for MaxLineLength is 256.
public java.lang.String getRemoteHost()
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 established.
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.
public void setRemoteHost(java.lang.String remoteHost)
throws IPWorksException
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 established.
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.
public java.lang.String getRemotePassword()
public void setRemotePassword(java.lang.String remotePassword)
throws IPWorksException
public int getRemotePort()
RemotePort property specifies the rexec 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.
public void setRemotePort(int remotePort)
throws IPWorksException
RemotePort property specifies the rexec 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.
public java.lang.String getRemoteUser()
public void setRemoteUser(java.lang.String remoteUser)
throws IPWorksException
public int getStderrPort()
Some systems do not support secondary stderr streams. Please refer
to the EnableStderr property for more information.
public void setStderrPort(int stderrPort)
throws IPWorksException
Some systems do not support secondary stderr streams. Please refer
to the EnableStderr property for more information.
public void setStdin(byte[] stdin)
throws IPWorksException
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
public int getTimeout()
Timeout property is set to 0 (default value), all
operations return immediately, potentially failing with an 'WOULDBLOCK' error if they can't be completed..
If Timeout is set to a positive value, the control will
automatically retry each operation that would otherwise result in a 'WOULDBLOCK' error for a maximum of Timeout seconds.
The control will use DoEvents to enter an efficient wait loop
during any potential waiting period, making sure that all system events
are processed immediately as they arrive. This ensures that the host
application does not "freeze" and remains responsive.
If the Timeout expires, and the operation is not yet complete, a Timeout error is fired.
public void setTimeout(int timeout)
throws IPWorksException
Timeout property is set to 0 (default value), all
operations return immediately, potentially failing with an 'WOULDBLOCK' error if they can't be completed..
If Timeout is set to a positive value, the control will
automatically retry each operation that would otherwise result in a 'WOULDBLOCK' error for a maximum of Timeout seconds.
The control will use DoEvents to enter an efficient wait loop
during any potential waiting period, making sure that all system events
are processed immediately as they arrive. This ensures that the host
application does not "freeze" and remains responsive.
If the Timeout expires, and the operation is not yet complete, a Timeout error is fired.
public void fireConnected(int statusCode,
java.lang.String description)
RexecConnectedEvent
public void fireDisconnected(int statusCode,
java.lang.String description)
RexecDisconnectedEvent
public void fireError(int errorCode,
java.lang.String description)
RexecErrorEvent
public void fireStderr(byte[] text,
boolean EOL)
RexecStderrEvent
public void fireStdout(byte[] text,
boolean EOL)
RexecStdoutEvent
public void disconnect()
throws IPWorksException
public void execute(java.lang.String command)
throws IPWorksException
Command property
to Command .
public void send(byte[] text)
throws IPWorksException
Stdin property
to Text .
public void addRexecEventListener(RexecEventListener l)
throws java.util.TooManyListenersException
public void removeRexecEventListener(RexecEventListener l)
|
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||