3270 is terminal?

Neil Johnson
Theropod
Published in
3 min readJul 18, 2022

🖥🖥
With all the development in mainframe modernization, you might think that the traditional way to access the mainframe would be the first thing to go. But 3270 terminals (well, terminal emulators) are still heavily used. And you don’t have to look hard to find reasons why terminal emulators continue to be important. There is plenty of new development — including Windows Terminal, a 3270 terminal emulator for Zowe, and the focus of this article…

I’m a software engineer at IBM that does z/OS development, and I want to introduce new open-source 3270 terminal emulation software: tnz. This python library / emulator may interest you if you write software that automates 3270 terminal interactions or if you just use a 3270 terminal emulator. You may find it especially interesting if you are also familiar with UNIX/ASCII terminals.

The tnz python package is pure python code with almost no dependencies, so it runs on any platform — including z/OS! It comes with a terminal emulator called zti that, like most python applications, runs in a terminal. In this case, a UNIX/ASCII terminal (or Windows Command Prompt).

PuTTY SSH connection to zti on z/OS connected to ISPF

The code in the package was originally written to automate 3270 terminal interaction. During z/OS development at IBM, python scripts use this package to run hundreds of z/OS testcases for hours on end. There are plenty of other libraries out there that can do this kind of automation, but this filled a need that the others couldn’t. Some other libraries were too low-level or needed to be compiled. The main API — ati — is based on an internal IBM tool that, when combined with python, seems to hit the sweet spot. There is no need to learn another macro language. Just familiarize yourself with the tnz APIs and write python code. It also comes with a py3270/s3270 API for those that have already invested there or that are hesitant to create a dependency on a newer project like tnz.

Installing it on a system that already has Python 3.8 (or higher) is simple:

pip install ebcdic tnz

You can use zti to connect to a tn3270 host from a terminal:

zti {hostname}
This is an example of using zti to connect to a server directly from the command line. Ctrl+W is used the close the session and exit zti.

If you are one of the unlucky ones that does not have the pip scripts directory in your PATH, you can use the slightly longer python command:

python -m tnz.zti {hostname}
This is an example of using the zti command prompt. The special session_ssl variable is used to turn off secure connections. A specific port on the server is specified. Ctrl+W is used to close the session before exiting the zti command prompt.

If you are interested in automation, get started with the examples or check out the documentation in ati.py.

--

--