BPXWUNIX - z/OS' Best Kept Secret?
MartinPacker 11000094DH Comments (8) Visits (22052)
Maybe you've all heard of BPXWUNIX. Maybe it's just me that hasn't. Hence the question mark in the title.
Seriously, I doubt this REXX function is as widely known about as it should be. And this post hopes to illustrate a little of its value.
Suppose you're writing a REXX program with a stem variable in it. Suppose you want to sort the strings in the stem variable:
or you might want to try the BPXWUNIX appr
Anyone familiar with Unix will know about stdin, stdout and stderr.
Now, there is a standard Unix sort program. This bears little resemblance to DFSORT. But that's not the point. Consider the following program:
The highlighted lines are the most interesting ones. Between them they execute the Unix sort command, marshalling stdin, stdout and stderr. The lines before set up the strings to be sorted and the ones after print the results. (You could source the strings and deal with the results any way you wanted.)
So this is quite simple. If you want to know more about sort go here (for example).
The simple command "sort" without parameters sorts the records alphabetically - based on each record's entire contents. That may not be what you want. So, without regurgitating the manual:
Of course, in this post sort is just an example. There are lots of Unix commands that could do things more easily than REXX could. And this might help along programmers who are primarily used to Unix.
I'm not sure, by the way, that continual crossing of the boundary between REXX and Unix commands is the highest performing thing to. But in this case we only do the round trip once. I've not done any performance tests but it seemed to be OK. I suspect that calling grep on a single line of data continually would perform well. But that's an extreme case.
What I fancy doing - when I get the time - is experimenting with the ideas for XML parsing here.
One limitation you should be aware of is that lines can only be up to 2048 characters long. Ordinarily that wouldn't be a problem - except for processing SMF. (Not that REXX can directly read SMF anyway. The standard dodge is to copy the VBS data to a transient VB data set and then process it with REXX.)
Any other examples of using BPXWUNIX you'd care to share?