As more and more organizations include heterogeneous operating systems such as MVS, OS/2, OS/400, UNIX, and NT in their enterprises, the need for communications between those platforms becomes more important. Until recently, intersystem communications have typically been limited to file transfers. Between MVS and a DOS, Windows, or OS/2 workstation, for example, file transfers were traditionally accomplished with IND$FILE GET and PUT. But since the multiplatform acceptance of TCP/IP, file transfers between systems are now frequently accomplished using the protocols File Transfer Protocol, more commonly known as FTP. However, cross-platform communications need not be limited to transferring files. Most TCP/IP implementations also permit remote command execution.
Imagine being able to execute a CL command or REXX program on an AS/400 from an OS/2 workstation or an MVS host, or even executing an MVS Time Sharing Option (TSO), OS/2 command, or REXX program from an AS/400. This is all possible now.
This article will introduce the basic TCP/IP functions used to effect remote command execution and the daemons (the service program with which a remote command communicates) necessary to support the execution on the target operating system. Note that this is the same remote command feature discussed in the July/August issue of Client Access/400 Expert, but instead of focusing on the implementation of Incoming Remote Command within Client Access/400, well be looking at the feature from the perspective the AS/400 and other servers in the network.
An Overview of the Available Remote Commands
Before discussing specific operating system implementations, an overview of the remote commands is in order. Remote Execution, REXEC for short, is a TCP/IP function that can execute a command on any remote system running REXECD, the REXEC daemon. This daemon must be started on the target system before it can accept remote commands from another system. For example, before executing a remote command from the AS/400 to an OS/2 workstation, the REXECD daemon would have to already be running on the OS/2 workstation. The same is true for Windows 95/NT or an RS/6000. This is similar to the requirements of FTP: You can only FTP to a system where FTPD, the FTP daemon, is already started. When this REXEC daemon is first started on the target system, a user ID and password are specified. (The actual specification differs slightly from platform to platform. On a Client Access/400 Windows 95/NT workstation, multiple user IDs and passwords can be set up as part of the configuration.) Later, when the remote system sends a command to this daemon using the REXEC command, a matching user ID and password for the target REXEC daemon will be required. These can be passed as part of the REXEBoth MVS TCP/IP and OS/2 TCP/IP support the REXEC client and REXECD daemon, which means they can send and execute remote commands via REXEC command. OS/400, however, implements remote commands a little differently. OS/400 supports the REXEC client, meaning it can initiate a remote command via Run Remote Command (RUNRMTCMD). OS/400 does not support the REXECD daemon program, although IBM has indicated in a statement of direction that the support may be forthcoming in the next release. The current hole in support means that you cannot make an AS/400 the target of an REXEC client call. A diagram of these relationships can be seen in Figure 1. However, the lack of support doesnt mean you cant execute a remote command on the AS/400. You can.
The current strategy for executing remote commands on an AS/400 is to exploit the RCMD support provided by the OS/400 TCP/IP FTP server. RCMD can issue a CL command on a remote AS/400, so at first glance it would seem similar to REXEC, but theres one subtle difference. When using REXEC, you essentially have a remote shell, and you receive the command output as is you were Telneting to the remote machine. Unfortunately, RCMD can not return program or command output. You can get around this shortcoming by coding your CL command or program to write its output to a file. Because youre already in an FTP stream executing the RCMD, you can follow the execution with an FTP GET statement for the output file. Exploiting a combination of either TCP/IP REXEC or RUNRMTCMD with FTP RCMD and GET will let users remotely execute commands on a target system and receive the output back at the originating system.
Executing a Remote Command from MVS
MVS TCP/IP runs as a started task and supports REXEC and FTP via the TSO READY prompt or batch. From TSO, you can execute commands via REXEC on remote OS/2 workstations running REXECD or other MVS systems running RXSERVE, the Remote Execution Server (its equivalent of REXECD). You can also execute commands on a remote AS/400 using the FTP Server subcommand, RCMD, to pass CL commands to a target system. A sample REXEC invocation specified at the TSO READY prompt looks like this:
rexec -l WSUID -p WSPSWD 111.222.33.444 f:_cmds estrcmd.cmd OS/2
In this example, -l indicates that the logon ID will follow, while -p indicates that the password follows. Here, the logon ID and password passed to OS/2 for authentication are WSUID and WSPSWD, respectively. (Warning: Case is significantvery significantto TCP/IP. If the logon ID is WSUID and you type in wsuid, they will not match!) Following the logon ID and password, you see is the target workstation TCP/IP address, in this example 111.222.33.444. The trailing data is sent to the REXECD daemon and is interpreted as the command line to be executed on the remote system. In this example, were executing the REXX command TESTRCMD (Figure 2) from the _CMDS directory
on the workstations F: drive. We are also passing the parameter OS/2. The output from this execution is illustrated in Figure 3. (You can specify other options on the REXEC invocation, but theyre not relevant to this discussion. However, if you would like to know more about them, just type REXEC by itself on the TSO command line, or refer to the references at the end of this article.)
In order to execute a remote command from MVS to an AS/400, the TSO user would need to first open an FTP connection then issue the RCMD which would take the following format:
quote rcmd STRREXPRC+
SRCMBR(TESTRCMD) SRCFILE(CHRISMIK/REXSRC) PARM(OS/400 SYS1)
Quote is an FTP subcommand indicating that the text following it is to be passed to the foreign host uninterpreted. The AS/400 FTP Server, then, recognizes the RCMD subcommand and executes the text that follows it.
In the preceding example, were executing the REXX command TESTRCMD (Figure 2) from the source file CHRISMIK/REXSRC passing the parameter OS/400 SYS1. (Remember that the output of the command is not returned, so the program output is not returned to the FTP stream.)
Executing a Remote Command on MVS
When configured to start the RXSERVE, MVS TCP/IP supports REXECD in a manner similar to OS/2, so the syntax described above for executing a remote command from MVS to OS/2 is the same for an invocation from OS/2 to MVS. But, REXEC is implemented a bit differently on the AS/400.
On the AS/400, RUNRMTCMD, not REXEC, is used. In the following example, which executes a REXX program on a remote MVS system, youll observe that the same information is passed on this RUNRMTCMD call as on the REXEC example above:
RUNRMTCMD+
CMD(ex dataset_name(TESTRCMD) MVS/TSO) RMTLOCNAME(111.222.33.444 *IP)
RMTUSER(uid) RMTPWD(passwd)
In this example, the REXX program TESTRCMD (Figure 2) found in dataset_name will be executed on the remote MVS machine. You should recognize the other parameters by now. Remember that RUNRMTCMD is really REXEC, so program or command output is returned to the user. However, unlike REXEC, RUNRMTCMD places the data in a spooled file that can be reviewed via the Work with Active Job command (WRKACTJOB), rather than returning it directly to the screen.
Executing a Remote Command from OS/2
The method for executing a command remotely from an OS/2 workstation is similar to the method Ive already discussed. When executing to MVS or another OS/2 workstation, use REXEC from an OS/2 window. When executing to an AS/400, use the RCMD FTP server subcommand from an open FTP connection.
Executing a Remote Command on OS/2
To execute a command remotely on an OS/2 workstation, you will again use either REXEC or RUNRMTCMD, based on the system you are executing the command from. The only real difference is that OS/2 REXECD must be started instead of RXSERVE. This can be done from an OS/2 window or via the TCP/IP Configuration application. When you start REXECD, youll need to supply USER and PASSWD values. This is the login/password pair specified when another system attempts to execute a remote command on that OS/2 workstation. It bears repeating that the login name and password are case- sensitive values.
Executing a Remote Command from OS/400
By now, you should understand that remote command support on the AS/400 is a little different than on MVS and OS/2 machines (and on UNIX and Wintel boxes, for that matter). To execute a remote command from the AS/400 to either MVS or OS/2 requires execution of the AS/400s equivalent of REXEC, RUNRMTCMD, which does not get program output returned directly to it, but rather to a spooled file. Thus, the output from the following command, which executes a DIR command on a remote OS/2 workstation, will be presented in a file as illustrated in Figure 4.
RUNRMTCMD CMD(DIR f:_cmds) RMTLOCNAME(111.222.33.444 *IP)+ RMTUSER(uid) RMTPWD(passwd)
Executing a Remote Command on OS/400
Executing a remote command from MVS and OS/2 workstation on an AS/400 requires the use of the RCMD FTP Server subcommand. Executing a remote command from another AS/400 also requires the use of RCMD. You may question the use of RCMD for AS/400-to-AS/400 execution because RUNRMTCMD is available on OS/400, but remember that RUNRMTCMD is the client half of the remote command process. It can only send remote commands, not receive them. Its the equivalent of REXEC, not the REXECD daemon.
Conclusion
Beyond file transfer, a valuable way to communicate across systems and platforms is by executing commands or programs on remote systems. TCP/IP provides REXEC, a flavor of which is implemented on most operating systems, including MVS, OS/2, OS/400, UNIX, and Windows. Remote commands can query system information and affect operations, giving users a high degree of enterprise control, even in heterogeneous environments.
References
AS/400 TCP/IP Configuration and Reference (SC41-3420-x) IBM TCP/IP for MVS, Users Guide (SC31-7136-x) IBM TCP/IP for OS/2: Users Guide (SC31-6075-x) OS/400 RQSxxx through WRKxxx Commands (SC41-4726-x)
REXEC vs. RSH
Remote Shell, or RSH, is similar to REXEC. The difference is in the way a user is validated. REXEC passes the USER and PASSWD to the remote system for authentication. RSH uses the originating TCP/IP address that is maintained on the remote systemÕs RHOSTS file. If the TCP/IP address of the origin user is in the remote systemÕs RHOSTS file (or other designated file which performs the same function) the RSH command is executed.
Thus, the command rsh 111.222.33.444 f:_cmds estrcmd.cmd ÔMy OS/2Õ when targeted to a remote system running RSHD (the RSH daemon), will have virtually the same effect as the
following command: rexec -l WSUID -p WSPSWD 111.222.33.444 f:_cmds estrcmd.cmd ÔMy OS/2Õ
You can look at the references included with this article for more information.
NETRC and RHOSTS
LATEST COMMENTS
MC Press Online