Writing Portable Shell Scripts on z/OS UNIX

z/OS UNIX

z/OS UNIX is a facet of z/OS that makes the operating system more approachable to those of us who weren’t brought up around 3270 terminals. Amongst other things, it provides support for remoting into the z/OS mainframe under a choice of UNIX shells (a simple Bourne-style shell or tcsh), access to a hierarchical file system, and a handful of Unix tools like ls, vi and grep (which work fine, as long as you don’t expect them to behave quite the same way as on other Unix systems). Like the rest of the operating system, z/OS UNIX is an EBCDIC environment.

EBCDIC Variants

My previous post brought up the topic of variant characters in EBCDIC. In summary, the characters shown below can be represented by different byte values depending on the locale under which a user is running:

^ ~ ! [ ] { } # | ` $ @

This raises following question: how can you distribute a z/OS UNIX shell script that will “just work” for any z/OS user, given that entities like the comment character (#), hashbang (#!), pipes (|) and the variable marker ($) might need to be represented by different bytes in different locales? Continue reading “Writing Portable Shell Scripts on z/OS UNIX”

If you � Unicode, you’ll ����� EBCDIC

One of the projects I’ve been working on over the past few months is the Dynamic Scripting feature pack for CICS. It runs on z/OS, which is an interesting environment for a few reasons – not least because it’s an EBCDIC platform.

Know your charset

A character set defines which byte value is used to represent a given character. So the choice of character set is a concern that should crop up whenever raw bytes are interpreted as character sequences, or character sequences are converted to raw bytes. For example, care should be taken to use the correct character set when writing text to a file, or reading character data from the body of an HTTP response.

Often, it’s tempting to ignore the concern. The vast majority of Continue reading “If you � Unicode, you’ll ����� EBCDIC”