TechTip: Read Printer Output with Qshell

CL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times
Everybody knows that spool files contain output, right? Well, that's not necessarily true. SPOOL is an acronym meaning Simultaneous Peripheral Operations Online. Spooling was originally developed for card readers, card punches, and printers as a way to speed up interaction with those slow devices. So input can be spooled as well as output. But there's another sense in which spool files can serve as input. It is common for shops that use packaged software--especially those shops that do not have the software's source code--to read and process spooled output from one of the package's programs in order to produce something more to their liking.

OS/400 programmers are familiar with CL's Copy Spool File (CPYSPLF) command, which copies spooled output to a database file. As of V5R3, Qshell includes a utility that is similar in function. Its name is catsplf, and it will be a welcome addition when my shop goes live with V5R3.

Catsplf is similar in function to the cat utility, which reads standard input (stdin) or disk files. Catsplf reads one or more spool files from a job and writes them to standard output (stdout). You may specify the job in one of two ways. Use the j option to specify the qualified job name using the OS/400 convention of jobnumber/user/jobname. Use the p option to specify the job name by its Qshell process ID. Whichever method you use, follow the job name with the name and number of the spool file. The spool file name and alpha portions of the job name are not case-sensitive, so you may use your preference of uppercase or lowercase letters. You may not use either the special values *ONLY and *LAST that CPYSPLF supports to specify the spool file number, or the special value * to indicate the current job.

The following examples illustrate both of these options. In both cases, the first spool file named QSYSPRT is copied to stdout.

catsplf -j 208922/pamsden/qzshchld qsysprt 1

catsplf -p 854 QSYSPRT 1

There are three other options that can be useful.

The a option tells Qshell to read all the spool files for a job. In this case, you do not follow the job identifier with a spool file name and number. Here are two equivalent expressions that use the a option:

catsplf -a -j 208922/PAMSDEN/QZSHCHLD

catsplf -aj 208922/PAMSDEN/QZSHCHLD

The e and n options number the lines as they are written to stdout. The difference between the two is that the e option ends each line with a dollar sign ($). Here are a couple of examples that use the e and n options:

catsplf -anj 208922/PAMSDEN/QZSHCHLD

catsplf -a -e -j 208922/PAMSDEN/QZSHCHLD

For more information about the catsplf utility, see IBM's iSeries Infocenter. To learn more about Qshell, I recommend Qshell for iSeries by Ted Holt and Fred A. Kulack.

Paul Amsden has worked with AS/400 and iSeries systems for more than 10 years.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$