Mainframe Path Start learning free
Core6 min readLesson 2 of 3

Working across the two worlds

The useful skills are the joins: running a shell script from JCL, copying data between datasets and files, and dealing with the fact that one side is EBCDIC and the other is often ASCII.

Copying between the two sides

cp works both directions
# dataset to Unix file
cp "//'PROD.PAY.REPORT'" /u/vsaha1/report.txt

# Unix file to dataset
cp /u/vsaha1/data.txt "//'DEV.PAY.INPUT'"

# a PDS member
cp "//'DEV.PAY.SOURCE(PAYSUM)'" ./paysum.cbl

# convert EBCDIC to ASCII on the way out
iconv -f IBM-1047 -t ISO8859-1 report.txt > report.ascii.txt
File tagging
# what is this file tagged as?
ls -T report.txt
  t IBM-1047    T=on  report.txt

# tag a file that arrived untagged
chtag -t -c ISO8859-1 incoming.csv

# remove a wrong tag
chtag -r broken.txt

Running Unix work from JCL

BPXBATCH: a shell script as a batch step
//RUNSH    EXEC PGM=BPXBATCH,
//            PARM='SH /u/vsaha1/scripts/extract.sh 20260930'
//STDOUT   DD PATH='/u/vsaha1/logs/extract.out',
//            PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//            PATHMODE=(SIRUSR,SIWUSR,SIRGRP)
//STDERR   DD PATH='/u/vsaha1/logs/extract.err',
//            PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//            PATHMODE=(SIRUSR,SIWUSR,SIRGRP)

A DD pointing straight at a Unix file

Any DD statement can name a Unix path instead of a dataset with PATH=. That means a COBOL program can read a Unix file with no code change — the SELECT still names a ddname, and the JCL decides what is behind it.

The commands worth knowing here

CommandDoes
obrowse / oeditBrowse or edit a Unix file from TSO
df -kFile system space — the first check when writes fail
chtag / ls -TCharacter-set tagging
iconvConvert between code pages
tso -t 'command'Run a TSO command from the shell
bpxmtextExplain a z/OS Unix errno value

Common mistakes

Ignoring file tagging

An untagged file may be converted or not converted depending on which tool touches it, giving results that differ between runs.

Assuming a text file transferred in binary is fine

Binary transfer of text between ASCII and EBCDIC systems produces unreadable data. Choose the transfer mode deliberately.

Running BPXBATCH without STDERR

You lose the error message entirely and are left with a bare return code.

Forgetting file system space

A full file system makes writes fail in ways that look like application bugs. df -k first.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← z/OS Unix in one pageWhere modern tooling fits →