Introduction to Mainframe Scripting Languages
Part Two: Automating the Machine's Everyday Work
Programming vs. Scripting
Programming languages on the mainframe build large, standalone applications — compiled, rigorously tested. Scripting languages automate tasks, manage datasets, and orchestrate the work those programs do. If you need to reliably process a bank's overnight transaction volume, you write COBOL. If you need to check whether a dataset exists and kick off a job, a REXX script is the sensible tool.
REXX
REXX (Restructured Extended Executor) is the most widely used scripting language on z/OS — designed to read almost like plain English, while remaining powerful enough for genuinely complex automation.
/* REXX */ ADDRESS TSO "LISTDS 'ZUBAIR.TEST.DATA'" IF RC = 0 THEN SAY 'Dataset exists, proceeding...' ELSE SAY 'Dataset not found, exiting.'
ADDRESS TSO sends the following command to TSO, and RC
captures its return code — a pattern you'll see constantly in real REXX scripts.
CLIST
CLIST (Command List) predates REXX, introduced in the 1970s as TSO's original scripting language — more utilitarian, less flexible. Most shops have migrated new automation to REXX, but decades-old CLIST scripts are still quietly running in plenty of places.
PROC 0 WRITE ENTER YOUR NAME: READ NAME WRITE HELLO, &NAME. WELCOME TO THE MAINFRAME.
Shell Scripting in USS
USS gives z/OS a genuine POSIX shell — sh, ksh, or bash — supporting exactly the kind of scripting you'd expect on any Linux system.
#!/bin/sh
for FILE in /u/zubair/logs/*.log
do
if grep -q "ERROR" "$FILE"; then
echo "Issues found in: $FILE"
fi
done
Nothing mainframe-specific here at all — and that's exactly the point. Skills learned scripting on any UNIX-like system transfer almost directly.
Comparing the Three
General-purpose, TSO-native
The right tool for most z/OS automation — powerful, readable, deeply integrated with TSO, ISPF, and even some system-level facilities.
Legacy, still present
Rarely the first choice for new automation work today. Understanding it mainly matters for maintaining or migrating existing scripts.
The natural choice for USS-side work
Best when your automation lives on the UNIX side of z/OS — the hierarchical file system, open-source tools, or modern DevOps pipelines.
Which Language Handles This Task?
Pick an automation task below and see which scripting language a real mainframer would typically reach for.
Automation Task Router
Where JCL Fits In
JCL is sometimes mistaken for a scripting language, but it's declarative, not procedural — it describes what a job needs, not step-by-step logic with loops and conditions. In practice, JCL and scripting work closely together: a REXX exec might dynamically build and submit a JCL job.
Summary
REXX, CLIST, and shell scripting in USS handle the automation and orchestration that keeps a mainframe's programs and jobs running smoothly. Learning to read return codes and interpret errors matters more early on than mastering any one language's full syntax.