Specifications

88 IBM System z Personal Development Tool: Volume 3 Additional Topics
An example of using the sample program might be:
//OGDEN22 JOB 1,OGDEN,MSGCLASS=X,MSGLEVEL=(0,0)
// EXEC PGM=AWSCMDX,PARM='ls -al '
//STEPLIB DD DSN=OGDEN.LIB.LOAD,DISP=SHR
//TAPE DD UNIT=(560,,DEFER),VOL=SER=123456,LABEL=(1,BLP),DSN=X
//SYSPRINT DD SYSOUT=*
The output (viewed from JES2 spool using SDSF) contains the usual JES2 messages and a
SYSOUT data set like the following:
COMMAND: ls -al 1>/tmp/AWSCMD-xxx-out.txt 2>/tmp/etc.xxetc
</tmp/AWSCMD.xxxetc
STDOUT: total 21699469
STDOUT: drwxrwxr-x 2 ibmsys1 ibmsys1 4096 Aug 1 20:01 .
STDOUT: drwdr-xr-x 4 ibmsys1 ibmsys1 4096 Aug 1 20:02 ..
STDOUT: -rw-rw-r-- 1 ibmsys1 ibmsys1 2846431232 Aug 8 09:58 WORK01
STDOUT: -rw-rw-r-- 1 ibmsys1 ibmsys1 2846431232 Aug 8 10:08 WORK02
(etc to list all the entries in the current Linux directory)
STDERR:
RTNCDE: 0
The Linux command that is actually executed contains redirection operators that are
automatically added by awscmd. You can see these operators in the output listing; they are
only suggested in the sample output shown here.
A second example, using SYSIN data to create a new Linux file, could be:
//OGDEN22 JOB 1,OGDEN,MSGCLASS=X,MSGLEVEL=(0,0)
// EXEC PGM=AWSCMDX
//STEPLIB DD DSN=OGDEN.LIB.LOAD,DISP=SHR
//TAPE DD UNIT=(560,,DEFER),VOL=SER=123456,LABEL=(1,BLP),DSN=X
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
tee my.new.file
This is a line of data for the new file
This is another line of data
And yet another
/*
This example would create Linux file my.new.file (in the Linux directory used to start zPDT)
with the indicated lines in the file. A fully-qualified Linux file name could be used with either of
the examples. The output for the second example would list all the data lines with the
COMMAND output and then list them again for STDOUT output. (This is because the tee
command writes all the stdin data to stdout. The tee command appends the new data if the
specified file already exists.)
7.2.1 Sample z/OS program for awscmd
The following listing is for a z/OS batch program, AWSCMDX, that exploits the awscmd
command processor to send a command to the underlying Linux and receive the results.
This sample program is simple-minded in many respects and is not intended to illustrate the
best programming techniques, but it should be fairly readable. Errors result in WTO
messages; this is a poor design for significant applications but it should be reasonable for
many zPDT environments. The program includes a two-second wait before reading the
results of the Linux command. This wait is not necessary and can be removed. (The