Modern Mainframe: 3 Common Unix commands, and their mainframe equivalents.

Toby Keegan
4 min readSep 24, 2021
A single frame IBM z15 | Credits: IBM

An important step in hiring new talent into the mainframe space is bridging the skill gap between young graduates who have spent their time learning Unix/Linux, and the vast world of mainframe.

When I first joined IBM, the only way I could do this was to tackle the enormous learning curve head-on. I was lucky: I worked in a team of highly experienced Systems Programmers who could really support me. I know that other’s aren’t so lucky.

In the past few years, I have seen improvements across the board in the ways in which we can interact with the mainframe. Personally, I’ve become comfortable with the ISPF environment and 3270 emulation. But for many, the command line is where they feel at home.

That’s why this guide will focus on the Z Open Automation Utilities (ZOAU). ZOAU provides a selection of command-line tools that allow those with very little mainframe experience quickly get things done, abstracting the complexities and nuances that are trivial to a more experienced mainframer.

I’ll break each one down into three parts:

  1. How it’s done in *nix
  2. How it’s traditionally done in z/OS
  3. How you can do it with ZOAU or Unix System Services

So, let’s get straight into it!

ls — the list utility

This common utility lists the contents of the directory you provide. This should look familiar to you:

$ ls
file1 file2 file3 dir1

Now, an important distinction here is that z/OS doesn’t have “files” and “directories” in a traditional way, but rather data sets. These can be sequential — like flat files where records are stored one after another, or partitioned, where one data set can contain many members (analagous to files in a directory, I suppose?)

So, how can we list our data sets in z/OS?

Interactively, it’s pretty simple. If you’re using ISPF, you can use the DSLIST menu. It looks like this:

ISPF Option DSLIST

But things get much more complicated if you want to copy this list into a file, pipe it into a script, etc.

That’s where ZOAU comes in with the dls and mls commands:

dls — List data sets under a qualifier

tobyk@winmvs4a ~ $ dls "TOBYK.*"
TOBYK.EPE.PLX
TOBYK.ISP06796.SPFLOG1.LIST
TOBYK.ISP08462.SPFLOG1.LIST
TOBYK.ISP08462.SPFTEMP1.CNTL
TOBYK.ISP12436.SPFLOG1.LIST
TOBYK.ISP17225.SPFLOG1.LIST
TOBYK.JCL.CNTL
TOBYK.LOG.MISC
TOBYK.MQGA.UCSQINST
TOBYK.P0262663.T0952905.C0000000
TOBYK.P0262663.T0973228.C0000001
TOBYK.PLX.CLIST
TOBYK.REXX.EXEC
TOBYK.SPF.ISPPROF
TOBYK.SPFLOG1.LIST
TOBYK.SPFTEMP0.CNTL
TOBYK.SPFTEMP1.CNTL

mls — List members in a PDS (Partitioned data set)

tobyk@winmvs4a ~ $ mls "TOBYK.JCL.CNTL"
$README
$TMPLATE
#CPYMBMR
#ZOAUTST
AUTHGRNT
BATCHDEL
CLANG
COPYMQ
COPYVOL

The advantage here is that you can use this output with other commands via standard unix pipes. For example, if I wanted to save a list of all my jobs containing the word “copy”:

$ mls "TOBYK.JCL.CNTL" | grep "COPY" > copyjobs.txt

It’s as easy as that!

ps — list processes

Running tasks in Unix-like operating systems usually reside as processes. On z/OS, it’s a little different. Users can run jobs, which are usually finite in time and do a specific thing. Or they can run started tasks which are longer-running and might be middleware like Websphere Application Server, MQ, or CICS.

The z/OS Unix System Services allows the standard ps command:

tobyk@winmvs44 ~ $ ps
PID TTY TIME CMD
83951780 ttyp0000 0:00 /bin/ps
67174992 ttyp0000 0:00 /bin/bash

but this will only show processes running in this subsystem. What if we want to see our z/OS jobs and started tasks? An experienced mainframer might use the SDSF (System Display and Search Facility):

SDSF’s Display Active Panel

In this example we are viewing all of MQTEST’s jobs on the system.

You might want a snapshot of the jobs running under a certain user ID at a certain time. This would be useful for performance monitoring, auditing, or logging.

With ZOAU (and a sprinkling of AWK knowledge 😉) you could save a list of jobnames with their ID’s like this:

$ jls "/MQTEST/*" | awk '$4 == "AC" {print $2 "," $3}' > output.txtIO470978,JOB15163
IO440993,JOB18132
IO450971,JOB50722
IO450987,JOB50727
IO450998,JOB51441

cat and echo

These two commands are used all the time. As a quick reminder:

You can use cat to print one or more files to stdout, or anywhere else you pipe to. For example, you could merge 2 files together like this:

$ cat fileA fileB > fileC

Similarly you can use echo to write something to your file:

$ echo "Hello, world!" > fileC

Merging two datasets in z/OS is usually achieved using system utilities such as IEBCOPY (which involves writing JCL and submitting a job, which we’re trying to avoid 🙂)

Luckily, ZOAU has us covered with the dcat and decho commands!

Note: dcat is freely available as a script in the ZOAU GitHub Repository, and is NOT included in ZOAU by default.

$ dcat "TOBYK.SAMPLE.TXT"
Hello, world!

and to add a line:

$ decho "Goodbye, world!" "TOBYK.SAMPLE.TXT"$ dcat "TOBYK.SAMPLE.TXT"
Hello, world!
Goodbye, world!

These commands only scratch the surface of the things you can do on a mainframe from the comfort of your command line. And this stuff continues to be developed, bringing more and more power to the fingertips of those that haven’t had years to understand the wonderful world of mainframe!

--

--