rexec(3N) rexec(3N)
NAME
rexec - execute command on a remote host
SYNOPSIS
#include <sys/socket.h>
int rexec(char **ahost, ushort rport, char *user,
char *passwd, char *cmd, int *fd2p);
DESCRIPTION
rexec() looks up the host *ahost using gethostbyname [see
gethostent(3N)], returning -1 if the host does not exist. Otherwise
*ahost is set to the standard name of the host. If a username and
password are both specified, then these are used to authenticate to
the foreign host; otherwise the environment and then the user's .netrc
file in his home directory are searched for appropriate information.
If all this fails, the user is prompted for the information.
The port inport specifies which well-known DARPA Internet port to use
for the connection. The protocol for connection is described in detail
in rexecd(1M).
If the call succeeds, a socket of type SOCKSTREAM is returned to the
caller. A control process is created on the remote host and executes
the cmd command. The standard input and output for the command is
redirected to the socket. If fd2p is non-zero, then an auxiliary chan-
nel to a control process will be set up. A descriptor for this channel
will be placed in *fd2p. The control process on the remote host
redirects standard error output to this channel. The control process
will also accept data on this channel that is sent as bytes and inter-
preted as signal numbers. The appropriate signal is forwarded to the
process group of the command. If fd2p is 0, then the standard error
output of the remote command is redirected together with the standard
output to the socket. If this happens, there is no way of sending
explicit signals to the command. It is, however, possible to use
"out-of-band" data to send any signals to the remote process.
NOTES
There is no way to specify options to the socket() call that rexec()
makes.
SEE ALSO
rexecd(1M), gethostent(3N), getservent(3N).
Page 1 Reliant UNIX 5.44 Printed 11/98