Thanks for the awk idea Kirk, I should have considered that solution myself.  I 
need to read up on the xargs command first though, I have not used it and need 
a better understanding of how it works.

Peter

-----Original Message-----
From: MVS OpenEdition <[email protected]> On Behalf Of Kirk Wolf
Sent: Monday, April 4, 2022 12:48 PM
To: [email protected]
Subject: Re: Running z/OS Unix commands from an MVS sequential dataset

EXTERNAL EMAIL

This is how I would do it.

- You can make awk not only act like (f)grep, but it also takes dsn syntax  
since uses fopen()
- awk will also read multiple files in one execution, so this will run rings 
around other ways that require a couple of forks for every dsn that you are 
searching.
- you can also customize how the output looks (see below)

//AWK  EXEC PGM=COZBATCH
//DSNS DD   *
"//'SYS1.MACLIB(ACB)'"
"//'SYS1.MACLIB(CHECK)'"
"//'SYS1.MACLIB(CLOSE)'"
"//'SYS1.MACLIB(DYNALLOC)'"
/*
//STDIN DD  *
fromdsn //DD:DSNS |
  xargs awk '/STR/ {print FILENAME ":" NR "\t" $0 }'
//

Replace STR above with your regex.
You can make this work with BPXBATCH and cat instead of fromdsn, but its not 
nearly as slick :-)

Kirk Wolf
Dovetailed Technologies
https://urldefense.com/v3/__http://dovetail.com__;!!Ebr-cpPeAnfNniQ8HSAI-g_K5b7VKg!YWy9o1XPpMwBL-at2HSefZAJ0ORxBp0McqmDmjob2R2NodfjeaVxqa6FcW_0T5fCjUVbIA$
 

Co:Z Toolkit is free to use under the terms of our Community License.   
Commercial license and support agreements are available.


On Sun, Apr 3, 2022, at 4:06 PM, Farley, Peter x23353 wrote:
> Thanks for the "fgrep -n" suggestion, that will definitely help in solving 
> the actual business issue.
>
> Using "sh -x" is not as helpful though because although you get a separate 
> output line for the "cat" of the MVS data set (good, would allow removal of 
> the "echo" command) but you also get another line for the piped "fgrep" 
> (not-so -useful noise).
>
> Now if fgrep actually accepted MVS data set syntax on its command line like 
> awk does then "sh -x" would be very useful, since the only command necessary 
> would be fgrep.  Perhaps the coming "unification" of the file systems will 
> help (once my employer's systems get to that OS level at some fairly long 
> time post-GA).
>
> Thanks again for your prompt and helpful assistance.
>
> Peter
>
> -----Original Message-----
> From: IBM Mainframe Discussion List <[email protected]> On 
> Behalf Of Paul Gilmartin
> Sent: Sunday, April 3, 2022 4:40 PM
> To: [email protected]
> Subject: Re: Running z/OS Unix commands from an MVS sequential dataset
>
> On Sun, 3 Apr 2022 19:35:34 +0000, Farley, Peter x23353 wrote:
>
> >That worked, got output to STDOUT as desired.
> >
> Yaaay!  (With no setup copy?)
>
> >Thankoyou for your help!
> >
> You' re welcome.  A couple extra thoughts:
>     // PARM='SH  /bin/cp //"''TSOUSER.UNIXCMDS.SH''" /dev/fd/1 | /bin/sh -x 
> 2>&1'
>
> "-x" logs the commands to identify data sets, merging that log with stdout.
>
> "fgrep -n" numbers the lines.
--

This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to