rexec()

execute command on remote machine (obsolete) 

Function


SYNOPSIS

#include <unistd.h>

int rexec(char **ahost, int inport, char *user, char *passwd, char *cmd, int *fd2p);


DESCRIPTION

Note:

This interface is made obsolete by rcmd(). It is available only for backwards compatibility, and code that uses it should be updated to newer functions.

The rexec() function looks up the specified host using gethostbyname(), returning -1 if the host does not exist. Otherwise, the name is updated 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 user's .netrc file in his home directory is searched for appropriate information. If this fails, the user is prompted for the information.

The specified port is used the Internet port to use for the connection. The call

getservbyname("exec", "tcp");

returns a pointer to a structure that contains the standard port number.

If the connection succeeds, a socket in the Internet domain of type SOCK_STREAM is returned to the caller, and given to the remote command as stdin and stdout. If fd2p is non-null, then an auxiliary channel to a control process is set up, and a descriptor for it is placed in that location to which it refers. The control process returns diagnostic output (stderr) from the command on this channel, and also accepts bytes on this channel as being UNIX signal numbers, to be forwarded to the process group of the command. The diagnostic information returned does not include remote authorization failure, as the secondary connection is set up after authorization has been verified. If fd2p is null, then the stderr of the remote command is made the same as the stdout and no provision is made for sending arbitrary signals to the remote process, although you may be able to get its attention by using out-of-band data.


PARAMETERS

ahost 

Points to the name of the host to which the connection is made. If the connection is successful, this name is updated with the standard name for the host.

inport 

Is the Internet port number on which the connection should be attempted.

user 

Is the user name to use for authentication. If this is a null pointer, the user's .netrc file is searched, and if an entry is not found, the user is prompted.

passwd 

Password to use for authentication. If this is a null pointer, the user's .netrc file is searched, and if an entry is not found, the user is prompted.

cmd 

Is the command to be executed on the remote host.

fd2p 

If non-null, a second connection is made to stderr of the remote command, and the file descriptor is returned through this pointer. If null, stderr of the remote command is connected to its stdout.


RETURN VALUES

On success, rexec() returns a file descriptor connected to stdin and stdout of the remote command. In addition, the name pointed to by ahost is updated to the standard name for the host, and if fd2p is non-null, an additional file descriptor is returned through that pointer, as described above. On failure, rexec() prints a diagnostic message to stderr and returns -1.


CONFORMANCE

4.4BSD


MULTITHREAD SAFETY LEVEL

Unsafe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
gethostbyname(), getservbyname(), rcmd(), socket()


PTC MKS Toolkit 10.2 Documentation Build 28.