remote execution 



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

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


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:


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.



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.


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

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.


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.



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

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


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.


Possible exit status values are:


Successful completion.


An error occurred.


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


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


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



File Formats:

MKS Toolkit Connectivity Solutions Guide

PTC MKS Toolkit 10.4 Documentation Build 39.