The sample code for these two TPs provides the ability to execute commands on a remote computer and to send the output back across the connection to the invoking TP.
AREXEC is a console application. The syntax of its command line is
arexec [-mmode] [-ttpname] destination command
where
The stdout and stderr from the command executed at the remote end is sent across the link and printed to stdout on the invoking end.
The AREXECD program is a Windows NT service, with the same routines as in APING, APINGD and multithreaded APINGD. The execution of the command and sending back of data are done in the routine execute_and_send_output in CPICPORT.C. It creates a named pipe and connects to the read end of the pipe. It then creates a process to run the command and gives that process a handle to the write end of the pipe as its stdout and stderr. Then the data is read from the pipe, and Send_Data is used to send it across the link.