|
The Remote Command protocol enables an application to execute
commands on a remote host, with the output of the command returned
to the client. The SocketTools control actually implements three
related protocols: rexec, rshell and rlogin. The choice of
protocols is determined by the port that is selected when a
connection is established.
Rexec The rexec protocol enables a client
application to execute a command on a remote host. Output from the
command is returned to the client and the connection is closed when
the command terminates. The client connects on port 512 and must
provide a user name and password to authenticate the session.
Rshell
The rshell protocol is similar to rexec in that it enables a client
to execute a command on a remote host. Output from the command is
returned to the client and the connection is closed when the
command terminates. The client connects on port 514 and must
provide a user name. The primary difference between the rexec and
rshell protocols is that rshell does not require a password.
Instead, it uses what is called "host equivalence" to determine if
the client is permitted to execute commands as that user. On a UNIX
based operating system, host equivalence is controlled by the
/etc/hosts.equiv and the .rhosts file in the user's home directory.
These files list the host names and user names which are permitted
to execute commands using the rshell protocol. Consult your
operating system manual pages for more information about how to
configure host equivalence.
Rlogin
The rlogin protocol is similar to Telnet in that it provides an
interactive terminal session. The connection is closed when the
user logs out or the shell process on the remote host is
terminated. The client connects on port 513 and must provide a user
name and terminal type. If there is an entry in the host
equivalence tables for the user and local host, then the client
will be automatically logged in and provided with a shell prompt.
If there is no host equivalence, the client will be prompted for a
password. The terminal emulation control can be used to provide
ANSI or DEC VT-220 emulation services if needed.
An important consideration when deciding whether to use rexec,
rshell or rlogin is how the server is configured and the type of
command being executed. If there is no entry for the local host in
the server's host equivalence tables, then the rexec command should
be used instead of rshell.
When using rexec or rshell, it is important to keep in mind that
although the command is executed with the privileges of the
specified user, that user is not actually logged in. The user's
login script is not executed and the program will not inherit the
user's normal environment as it would during an interactive
session. If you are connecting to a UNIX system, you should not
attempt to execute programs which try to put standard input into
raw mode; an example of this would be the vi editor. If you are
connecting to a Windows system, you should not execute a program
which uses a graphical interface. Only programs which read standard
input and write to standard output are suitable for use with rexec
or rshell.
The following methods are available for use by your
application:
Initialize
Initialize the control and load the Windows Sockets library for the
current process. This method is normally not used if the control is
placed on a form in languages such as Visual Basic. However, if the
control is being created dynamically using a method similar to
CreateObject, then the application must call this method to
initialize the component before setting any properties or calling
any other methods in the control.
Execute
Execute the specified command on the remote host. The rshell or
rexec protocol is selected based on the port number that is
specified. Output from the command will be returned to the client
to be read. When the command terminates, the connection to the
server will be closed.
Login
Establish an interactive login session which is similar to how the
Telnet protocol works. If there is no host equivalence with the
local host, you will be prompted for a password. Output from the
session will be returned to the client, and when the client logs
out the connection will be closed.
Read
Read the output generated by the command. Your application would
typically call this method in a loop until all of the data has been
read or an error occurs.
Search
Search for a specific sequence of characters in the output returned
by the remote host. The method returns when the sequence is
encountered or when a timeout occurs. The data captured up to the
point where the character sequence was matched is returned to the
caller for processing.
Disconnect
Disconnect from the server and release any resources that have been
allocated for the client session. After this method is called, the
client session is no longer valid.
Uninitialize
Unload the Windows Sockets library and release any resources that
have been allocated for the current process. This is the last
method call that the application should make prior to terminating.
This is only necessary if the application has previously called the
Initialize method.
|