MVS printouts
MVS specific work
Automation; a script
Now, following Tim’s webpage, I made a prtpdf script and altered it to suit my TK4- needs. The script will take all .txt files it finds in the specified directory, convert them to pdf files and delete them when done. The names of the constructed pdf files are derived from the MVS TK4- separator pages and will look like NNNN-MMMMMMMM.pdf where:
- NNNN is the jobnumber
- MMMMMMMM is the jobname
#!/bin/bash
if [ "$#" != 2 ]
then
exit
fi
cd $2
for i in *.txt
do
echo $i
JOBNAME=`grep -m 1 'START' $i | cut -c25-32 | sed 's/\s//g'`
JOBNUM=`grep -m 1 'START' $i | cut -c19-22 | sed 's/\s/0/g'`
enscript --quiet --font=Courier-Bold@8 -l -H1 -r --margins=25:25:40:40 -p - ${i} | ps2pdf - ${JOBNUM}-${JOBNAME}.pdf
chmod 777 ${JOBNUM}-${JOBNAME}.pdf
rm $i
done
#
# ### in the process a file name '-.pdf' comes out. It's empty, so we delete it
#
if [ -f "./-.pdf" ]
then
rm "./-.pdf"
fi
Now hooking it up…
The last step is to hook up our script somehow to our S/370 Hercules printer. That can be done, we need one more program called prtspool. You can download it from Tim’s webpage, at the bottom. For Linux, be sure to download the tar.gz file. There’s executables in there, but I decided to compile them on my (ARM) system, just to be sure. This prtspool program can be used in two ways.
Process existing output
We can use it to process already existing output that will be in one big file for a given printer (something like ‘prt00f.txt’). When we (manually) give it this command:
cat prt00f.txt | ~/prg/c/prtspool P ./classP/
it will go through the file prt00f.txt and split it up into separate .txt files in the given directory (in this case ./classP). It does that by searching until it finds the END job separator page – 4 consecutive lines all containing ‘****P. END’, where ‘P’ is the output class – after which it will split the file and start a new one. After it is finished we have a series of .txt files in the designated directory. We then can use our scripts to convert them to pdf’s.
Process S/370 output
To catch every job from MVS TK4- we have to connect the specific printer to prtspool and then have it execute our script at the end. Then we will have automated our printing to PDF!
There is a line in [tk4-dir]/conf/tk4-.cnf that has to be replaced. Below you can see my replacement. It ‘pipes’ the printer output to the prtspool program, that in turn searches for class A jobs and transfers them to the prt/classA directory; subsequently, per job it transfers control to the prtpdf script mentioned earlier, that in turn produces a PDF file.
#000E 1403 prt/prt00e.txt ${TK4CRLF}
000E 1403 "|prtspool A /var/www/geronimo370.nl/html/classa/ prtpdf"
Here’s the proof, I submitted job ALGSAMP2 from SYS2.JCLLIB and presto! there it is, in PDF format in the …/prt/classA directory!