If you regularly work with USS, the Unix Environment of z/OS, you know these Challenges:
- Dealing with the various Codepages on the mainframe never becomes an automatic. It usually feels adventurous to guess if a certain tool expects UTF8 or EBCDIC encoded files. More so a wild mixture of localized EBCDIC Codepages like IBM-1047 and IBM-1141 adds to the complexity.
- The interoperability between the Unix world and the classic MVS world is major feature of USS, but it bears further challenges.
- Some of the tools that you know from other unix environments work differently, don’t properly do their job or simply don’t exist.
Many of these challenges can be met more easily if you optimize the configuration of your shell environment. We show you what configuration actions we perform to make our lives easier.
Step 1: a (somewhat) current bash version
Sadly the default on USS is a /bin/sh shell simply called “the z/OS shell”. I rather let IBM characterize it themselves:
The z/OS shell is modeled after the UNIX System V shell with some of the features found in the Korn shell. As implemented for z/OS UNIX System Services, this shell conforms to POSIX standard 1003.2, which has been adopted as ISO/IEC International Standard 9945-2: 1992.
There is no auto completion, it is very inconvenient dealing with command-input chars (like backspace, tab or alike), and the scripting capabilities are limited. So this shell can not be recommended for anyone that has to interact with USS on a regular basis.
IBM also ships a bash with z/OS. Is this the solution? Well…
This bash version was released in 1999, which makes it 24 years old. Even in z/OS release cycles of user interfaces and command shells usually are not that long.
So the first step should be to use the bash of the rocket tools. This bash is a version 4.3 and therefor “only” 9 years old. This shell is quite up to standard regarding modern quality-of-life shell features.
Step 2: an optimized configuration of your shell environment
First thing first: For all our configs we have created a setup script that you can find here: https://github.com/Living-Mainframe/uss-init
It should create configurations that fit most purposes and requirements. It’s quite easy to apply these settings, given your mainframe environment has internet connectivity:
sh uss-init.sh bashrc aliases clear exports
What are the configs that are applied?
- creates and tags a new empty “~/.bashrc” if it does not yet exist
- adds aliases for common tools to conviniently handle UTF8 encoded files
- adds a working “clear” as an alias and as cntrl^L
- adds some common environment variables to ~/.profile to more consistently handle file encoding
This function creates and tags an empty .bashrc file (as ISO 8859-1) in your user’s home directory.
This function creates aliases for some important file tools to easier handle UTF8 encoded files.
ucat is an alias for cat -W filecodeset=UTF8. This lets you view UTF-8 encoded files by just issuing ucat file.txt.
ugrep is an alias for grep -W filecodeset=UTF8. This lets you use grep on UTF-8 encoded files by just issuing ugrep “string” file.txt.
uvi is an alias for vi -W filecodeset=UTF8. This lets you edit UTF-8 encoded files by just issuing uvi file.txt.
This function creates a working clear command via an alias to a special printf string. Additionally it put the clear command in the .inputrc in your user’s home directory. This way you can use CNTL-L to clear the screen.
This function adds some common environment variables to your user’s .profile that aid with the right encoding and tagging of files that you newly create:
export _BPXK_AUTOCVT=ON export _TAG_REDIR_ERR=txt export _TAG_REDIR_IN=txt export _TAG_REDIR_OUT=txt export _CEE_RUNOPTS="$_CEE_RUNOPTS FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
Please give us feedback and tell us:
- If the configs work for you
- What is missing
- What additional config optimizations (beyond the USS shell and bash) you think everyone should have
We are looking forward for your suggestions!