[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Communications Technical Reference, Volume 2

rexec Subroutine

Purpose

Allows command execution on a remote host.

Library

Standard C Library (libc.a)

Syntax

int rexec (Host, Port, User, Passwd, Command, ErrFileDescParam)
char **Host;
int Port;
char *User, *Passwd, 
*Command;
int *ErrFileDescParam;

Description

The rexec subroutine allows the calling process to start commands on a remote host.

If the rexec 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.

Parameters

Host Contains the name of a remote host that is listed in the /etc/hosts file or /etc/resolv.config file. If the name of the host is not found in either file, the rexec subroutine is unsuccessful.
Port 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 library call:
getservbyname("exec","tcp")
User and Passwd Points 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 $HOME/.netrc that contains a user ID and password.
  3. Prompts the user for a user ID and password.
Command Points to the name of the command to be executed at the remote host.
ErrFileDescParam Specifies one of the following values:
Non-zero Indicates an auxiliary channel to a control process is set up, and a descriptor for it is placed in the ErrFileDescParam parameter. 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 connection is set up after authorization has been verified.
0 Indicates 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 Values

Upon successful completion, the system returns a socket to the remote command.

If the rexec subroutine is unsuccessful, the system returns a -1 indicating that the specified host name does not exist.

Implementation Specifics

The rexec subroutine is part of Base Operating System (BOS) Runtime.

All applications containing the rexec subroutine must be compiled with _BSD set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.

Files

/etc/hosts Contains host names and their addresses for hosts in a network. This file is used to resolve a host name into an Internet address.
/etc/resolv.conf Contains the name server and domain name.
$HOME/.netrc Contains automatic login information.

Related Information

The getservbyname subroutine, rcmd subroutine, rresvport subroutine, ruserok subroutine.

The rexecd daemon.

The TCP/IP Overview for System Management in AIX Version 4.3 System Management Guide: Communications and Networks.

Sockets Overview in AIX Version 4.3 Communications Programming Concepts.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]