shellunixzosjcl

How to write long z/OS UNIX shell commands in BPXBATCH


I'm going to describe my issue as well as possible.

I know in advance that is is possible to type a z/OS shell UNIX command that does not fit on one line using a backslash at the end of the first line. In fact I've tested it in the computer I'm working with and executes well.

For example; in order to do a test I've type ls command as follows:

Firstly without backslash from the command line:

ls -la

After with backslash also from the command line:

ls\
 -la

I get the same good results

What I would like to know is how to do the same in a z/OS UNIX shell script in STDIN executed with BPXBATCH.

If I put the command as follows ls -la it executes well; but If I try to break it in two lines it does not work.

May anyone shed light in this issue?.

Many thaks in advance

(Obvioulsy ls -la is a very simple example only intended to show the problem I'm facing; real commands are much more larger)


Solution

  • I'll take a stab at this. Using BPXBATCH, you want to issue a shell command. Here would be a simple example:

    //TSTRADMB  JOB  MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=0M
    //BPXIT EXEC PGM=BPXBATCH,PARM='SH ls -l'
    //BPXPRINT DD SYSOUT=*
    //STDOUT DD SYSOUT=*
    //STDERR DD SYSOUT=*
    

    This has the desired effect of writing the output of the shell command ls -l to stdout. But - what if it's a much longer string? Two ways you could go. One would be to write a wrapper script and call it from BPXBATCH (which is what I would do). The other would be to put the PARM across multiple lines, in which case you need to follow JCL rules for continuation (using a + in column 72 works), e.g.

    //TSTRADMB  JOB  MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=0M
    //BPXIT EXEC PGM=BPXBATCH,PARM='SH ls -l "/u/tstradm/ThisIsAReallyLongD+
    //             irectoryThatCrossesMultipleLines"'
    //BPXPRINT DD SYSOUT=*
    //STDOUT DD SYSOUT=*
    //STDERR DD SYSOUT=*
    

    The spacing with JCL is truly annoying - so you have to get it right. That + sign has to be in column 72 or you get a JCL error. The start of the next line of text begins in column 16. Start it late and you end up with blanks (which in this case would make a difference).