rexec

remote execution 

Command


SYNOPSIS

rexec [username@hostname] [-DNn] [-l username] [-p password] command

rexec [-DNn] [-l username] [-p password] [username@hostname] command


DESCRIPTION

rexec executes the specified command on a remote host. The remote host must be running a rexecd service (or daemon) for rexec to connect to.

If a remote user name is not specified with either the -l option or with username@hostname, the ~/.netrc file is checked for a "machine hostname login username" combination. If no user name is found, the local user name is used.

Non-quoted shell metacharacters on the command line are interpreted on the local machine, while quoted metacharacters are interpreted on the remote machine. For example, the command

rexec otherhost cat remotefile >> localfile

appends the remote file remotefile to the local file localfile, while

rexec otherhost cat remotefile \>\> other_remotefile

appends remotefile to other_remotefile.

rexec copies its standard input to the remote command, the standard output of the remote command to its standard output, and the standard error of the remote command to its standard error (unless you specify -N).

rexec normally terminates when the remote command does.

If rexec fails with a TIMEOUT error on Windows 8.1/2012R2/10/2016/2019/11/2022 when it should have succeeded, the user can tell rexec to retry with:

export TK_WORK_AROUND_VISTA_TIMEOUT_BUG=1

A TIMEOUT error is indicated by the following error message:

A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond.

Options

-D 

enables socket debugging on the TCP sockets used for communication with the remote host. This option also the displays the user name sent to the rexecd service (or daemon).

-l username 

specifies the remote user name to be used when executing the command. This can also be specified by including username@hostname on the command line.

-N 

does not generate a separate standard error stream. All output is sent to standard output. This is useful when you are running an interactive command. For example,

rexec -N localhost cmd
rexec -N localhost sh -i
-n 

redirects input from the special device /dev/nul.

-p password 

specifies the password of the specified user on the remote host.

If no password is specified, the ~/.netrc file is checked for "machine hostname login username password string" combination. If a password is not found, the user is prompted to enter a password.

Troubleshooting

If you are having trouble connecting to rexecd on a remote host, here are some possible solutions to your problems.

If you are receiving connection to server failed error, it usually implies that either there is no rexecd service (or daemon) running on the remote host or that there were more concurrent rexec requests than the remote host could handle.

Most versions of rexecd have a limit to the length of user name they can handle. On some UNIX systems, this limit is as low as 14 characters. As a result, you may receive an error message stating that the user name is too long. If you receive this message, make sure that the user name specified is valid on the remote host.


ENVIRONMENT VARIABLES

TK_RETRY_ON_WSAENOTSOCK 

When this environment varible is set, the rsh, rcp, rexec, and rlogin utilities retry up to five times if they get the WSAENOTSOCK error. The WSAENOTSOCK error is reported as:

An operation was attempted on something that is not a socket
TK_REXEC_RETRY_IF_LOGIN_INCORRECT 

When this environment variable is set and rexec fails with a "login incorrect" message from rexecd, rexec will make one additional attempt to connect.

TK_WORK_AROUND_VISTA_TIMEOUT_BUG 

when set, rexec retries to establish a connection when it fails with a TIMEOUT error on Windows 8.1/2012R2/10/2016/2019/11/2022.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

>0 

An error occurred.


ACKNOWLEDGEMENT

This product includes software developed by the University of California, Berkeley and its contributors.


PORTABILITY

All UNIX systems. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.


AVAILABILITY

PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
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

Commands:
rexecd

File Formats:
netrc

MKS Toolkit Connectivity Solutions Guide


PTC MKS Toolkit 10.4 Documentation Build 39.