rexec
Purpose
Allows command execution on a remote host.
Library
Sockets Library (libsock.a)
Syntax
int rexec (host, port, user, passwd, command, errfdp)
char **host;
int port;
char *user, *passwd, *command;
int *errfdp
Description
The rexec subroutine allows the calling process to
execute commands on a remote host.
The host parameter contains the name of a remote host
that is listed in the /etc/hosts file. If the name of
the host is not found in this file, the rexec fails.
The port parameter specifies the well-known DARPA
Internet port to use for the connection. A pointer to
the structure that contains the necessary port can be
obtained by issuing the following call:
getservbyname("exec", "tcp")
The protocol for the connection is described in detail in
the discussion of rexecd in Interface Program for use
with TCP/IP.
The user and passwd parameters point to a user ID and
password valid at the host. If these parameters are not
supplied, the rexec subroutine takes the following
actions until finding a user ID and password to send to
the remote host:
1. Searches the current environment for the user ID and
password on the remote host.
2. Searches the user's home directory for a file called
.netrc that contains a user ID and password.
3. Prompts the user for a user ID and password.
The command parameter points to the name of the command
to be executed at the remote host.
If the connection succeeds, a socket in the Internet
domain of type SOCK_STREAM is returned to the calling
process and is given to the remote command as standard
input and standard output.
If errfdp is not 0, an auxiliary channel to a control
process is set up, and a descriptor for it is placed in
*errfdp. The control process provides diagnostic output
from the remote command on this channel and also accepts
bytes as signal numbers to be forwarded to the process
group of the command. This diagnostic information does
not include remote authorization failure, since this con-
nection is set up after authorization has been verified.
If errfdp is 0, then the standard error of the remote
command is the same as standard output, and no provision
is made for sending arbitrary signals to the remote
process. In this case, however, it may be possible to
send out-of-band data to the remote command.
Return Value
The rexec subroutine fails and a value of -1 is returned
if the specified host name does not exist.
Related Information
In this book: "rcmd, rresvport, ruserok."
The discussion of rexecd and /etc/hosts in Interface
Program for use with TCP/IP.