I'm trying to write a script that would query specific resource profiles in a RACF class and later do a bit of logic to match a few things - not relevant.
The problem is that when I issue the command below I get the AUDIT TRAIL on the terminal. The script is meant to just return a 1 or a 0. All the logic works as it should but when I run the script I get the whole AUDIT TRAIL from RACF and at the bottom the result.
y = outtrap('resourceAccess.')
address tso 'RLIST CLASSX CLASSX.RESOURCE.LIST'
y = outtrap('off')
I already tried to create another outtrap
after the one above with no success.
Is there a way to remove that AUDIT TRAIL bit?
It's possible that those lines of text are being issued in such a way that they cannot be trapped using outtrap
and are instead being placed on the external data queue (EDQ) and then echoed to the terminal when the REXX exits. ACF2 does this with all output, making trapping command responses a bit tricky.
Try this:
/* Trap command response*/
y = outtrap('temp.')
address tso 'RLIST CLASSX CLASSX.RESOURCE.LIST'
y = outtrap('off')
/* Display anything put onto the EDQ */
do queued()
pull line
say line
end
Old answer: If the output you are getting matches what's in the IBM docs you linked to (https://www.ibm.com/docs/en/szs/2.2?topic=effects-command-audit-trail), then what you need to do is after to have trapped the output, simply discard the first 2 lines, (which should be):
Command Audit Trail for USER IBMUSER
(one line of text and a blank line).
You could do this as follows:
y = outtrap('temp.')
address tso 'RLIST CLASSX CLASSX.RESOURCE.LIST'
y = outtrap('off')
/* Copy from the 3rd command response line into our 'real' response var */
do tempIndex = 3 to temp.0
desiredIndex = tempIndex - 2
resourceAccess.desiredIndex = temp.tempIndex
end
resourceAccess.0 = temp.0 - 2 /* Set number of lines */