Skip to content

Commit

Permalink
Shell command example (#40)
Browse files Browse the repository at this point in the history
* added shell example

* added shell example
  • Loading branch information
Mike Fulton authored and drbruce-git committed Aug 21, 2019
1 parent 16893a2 commit 7ed373c
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Automation/Merge/ShellMerge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Shell Merge Sample

This is a sample to demonstrate how to use the Z Open Automation Utilities shell commands to merge two datasets.

The sample creates two datasets to merge, a command dataset, and a merge dataset that contains the output from the sort command.
mvscmd is then used to call the sort command to sort and merge the two datasets together.

One must modify the setenv.sh file with the appropriate values for your installation of Java and your installation of Z Open Automation Utilities before running this sample.

Run `merge.sh -?` for information about program parameters.
70 changes: 70 additions & 0 deletions Automation/Merge/ShellMerge/merge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/sh
syntax() {
echo "merge.sh <qualifier>"
echo " where <qualifier> is the qualifier to create datasets under."
exit 16
}

num=$#
if [[ ${num} -eq 0 ]]; then
syntax
fi
if [[ ${num} -gt 1 ]]; then
syntax
fi
if [ "$1" = "-?" ]; then
syntax
fi
prefix="$1"

echo "Dataset prefix: ${prefix}"

master="${prefix}.master"
new="${prefix}.new"
cmd="${prefix}.cmd"
merge="${prefix}.merge"

echo "Delete the sample datasets if they already exist"
ds="${master} ${new} ${cmd} ${merge}"
for d in ${ds}; do
drm -f "${d}"
done

echo "Allocate the sample sequential datasets as FB 80 (the default for sequential datasets)"
for d in ${ds}; do
dtouch -tseq "${d}"
done

echo "Write 3 records to master dataset"
decho "Charles Field 278 323 6045" "${master}"
decho -a "David George 397 132 6025" "${master}"
decho -a "William Young 178 333 5045" "${master}"

echo "Write 3 records to new dataset"
decho "Emma Hill 149 589 5045" "${new}"
decho -a "Sharon Miller 153 232 6045" "${new}"
decho -a "Steve Green 748 111 6025" "${new}"

echo "Write the command string to the command dataset"
decho " MERGE FORMAT=CH,FIELDS=(1,9,A)" "${cmd}"

args="MSGPRT=CRITICAL,LIST"
echo "The arguments to the SORT program for performing the merge are: ${args}"

echo "Run the SORT program to perform the merge."
echo "SORTIN01 DD name points to the master (old) dataset: ${master}"
echo "SORTIN02 DD name points to the new dataset: ${new}"
echo "SYSIN DD name points to the commands dataset: ${cmd}"
echo "SORTOUT DD name points to the resulting merged dataset: ${merge}"
echo "SYSOUT DD name points to the console for output from the program"

mvscmd --pgm=SORT --args="${args}" --sortin01="${master}" --sortin02="${new}" --sysin="${cmd}" --sortout="${merge}" --sysout=*
rc=$?

if [[ "${rc}" -eq 0 ]]; then
echo "Datasets successfully merged into: ${merge}"
else
echo "Datasets were not successfully merged. Return code: ${rc}"
fi
exit ${rc}

15 changes: 15 additions & 0 deletions Automation/Merge/ShellMerge/setenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
#*******************************************************************************
# Licensed Materials - Property of IBM
# (c) Copyright IBM Corporation 2019. All Rights Reserved.
#
# Note to U.S. Government Users Restricted Rights:
# Use, duplication or disclosure restricted by GSA ADP Schedule
# Contract with IBM Corp.
#*******************************************************************************
#
# Set up the environment
# NOTE: Before running this script, you need to have modified this file to match your z/OS system
#
export ZOAUTIL_DIR=/usr/lpp/IBM/zoa
export PATH=${ZOAUTIL_DIR}/bin:$PATH
2 changes: 1 addition & 1 deletion Automation/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Automation
This category contains examples of using DBB to easily automate common DevOps tasks on z/OS.
This category contains examples of using Z Open Automation Utilities to easily automate common DevOps tasks on z/OS.

0 comments on commit 7ed373c

Please sign in to comment.