I'm using sed/awk to parse mq runmqsc output. We want to get certain fields displayed on a single line. This seems to be a straightforward sed/awk problem.
echo "display conn(*) ALL" |
runmqsc <BrokerName> |
awk '{ RS = "AMQ8276: Display Connection details." } ; { print $0 }' |
sed -e 's/( )/()/g'
5724-H72 (C) Copyright IBM Corp. 1994, 2009. ALL RIGHTS RESERVED. Starting MQSC for queue manager .
1 : display conn(*) ALL
CONN(3923A95601000020)
EXTCONN(414D51435465737442726F6B65725553)
TYPE(CONN)
PID(9263) TID(1)
APPLDESC(WebSphere MQ Object Authority Manager)
APPLTAG(amqzfuma) APPLTYPE(SYSTEM)
ASTATE(NONE) CHANNEL()
CONNAME() CONNOPTS(MQCNO_FASTPATH_BINDING)
USERID(mqm) UOWLOG()
UOWSTDA() UOWSTTI()
UOWLOGDA() UOWLOGTI()
URTYPE(QMGR)
EXTURID(XA_FORMATID[00000000] XA_GTRID[] XA_BQUAL[])
QMURID(0.0) UOWSTATE(NONE)
This code:
echo "display conn(*) ALL" | runmqsc TestBrokerUS | awk '{ RS = "AMQ8276: Display Connection details." } ; { print $0 }' | sed -e 's/( )/()/g' |
sed -n -e 's/^.* CHANNEL(\(.*\).*) /\1/p' -e 's/^.* USERID(\(.*\).*)/\1/p' -e 's/^.* CONNOPTS(\(.*\).*)/\1/p' -e 's/^.* CONN(\(.*\).*)/\1/p' -e 's/^.* CONNAME(\(.*\).*)/\1/p'
Returns this:
3923A95601000020)
) CONNOPTS(MQCNO_FASTPATH_BINDING)
Need to parse out these fields on 1 line. Thoughts?
awk
'ssub()
function. You can addsub(/[(] [)]/,"()", $0)
(orgsub(...)
if you need global sub) instead of addingsed
to the pipeline. Good luck. – shellter