On Apr 4, 2022, at 19:08:47, Kirk Wolf wrote:
>
> $(fromdsn //DD:DSNS)
> returns a multiline string as one arg.
>
But since $( ... ) is unquoted, shell tokenizes it as awk needs:
598 $ echo $( cat dsns )
"//'SYS1.MACLIB(ACB)'" "//'SYS1.MACLIB(CHECK)'" "//'SYS1.MACLIB(CLOSE)'"
"//'SYS1.MACLIB(DYNALLOC)'"
almost like:
601 $ cat dsns | xargs echo
//'SYS1.MACLIB(ACB)' //'SYS1.MACLIB(CHECK)' //'SYS1.MACLIB(CLOSE)'
//'SYS1.MACLIB(DYNALLOC)'
versus:
599 $ echo "$( cat dsns )"
"//'SYS1.MACLIB(ACB)'"
"//'SYS1.MACLIB(CHECK)'"
"//'SYS1.MACLIB(CLOSE)'"
"//'SYS1.MACLIB(DYNALLOC)'"
But don't the quotation marks confuse fopen() in awk? Or does
fromdsn magically strip those? Ah! I see xargs strips them!
> ... Actually it won't work, since $( ) does a fork into a different
> address space and the DD isn't there.
>
OK. COZBATCH runs ini the job step address space. And it
can spawn() sh locally into that same address space. But
doesn't sh need to fork() fromdsn to run the pipe, thereby
losing the "//DSNS DD *"?
> xargs is completely different, but works perfectly for when you want to
> tokenize a stream into additional arguments for a command.
>
Does it tokenize differently from sh? Yes, but not here.
>> On Apr 4, 2022, at 10:47:36, Kirk Wolf wrote:
>>> ...
>>> //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 }'
>>> //
--
gil
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN