I searched in the answer with no succes... On RHEL Linux, A first command lists this (I put exactly what I get for those how want to test...):
ps -eaf | grep lsnr | grep -v ' LISTENER ' | grep -v grep
oracle 10258 1 0 2014 ? 01:34:43 /logicielPR1/oracle/product/11.2.0.4/bin/tnslsnr PRXPLO -inherit
oracle 10442 1 0 2014 ? 00:24:30 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TECHIMIO -inherit
oracle 10473 1 0 2014 ? 00:28:50 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TEIAC -inherit
oracle 10566 1 0 2014 ? 00:24:50 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TEIMG -inherit
oracle 14192 1 0 2014 ? 00:22:09 /logicielPR1/oracle/product/11.2.0.4/bin/tnslsnr PROCTM2 -inherit
oracle 27167 1 0 2014 ? 00:19:26 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TEOCTM -inherit
oracle 36854 1 0 2014 ? 00:19:59 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TEANA -inherit
oracle 37235 1 0 May20 ? 00:08:32 /logicielPR1/oracle/product/11.2.0.4/bin/tnslsnr PRCHIMIO -inherit
oracle 45141 1 0 Jun03 ? 00:08:02 /logicielST1/oracle/product/11.2.0.4/bin/tnslsnr PRIACS -inherit
oracle 48241 1 0 Sep25 ? 00:04:39 /logicielPR1/oracle/product/11.2.0.4/bin/tnslsnr PRINL -inherit
oracle 48708 1 0 Sep25 ? 00:03:27 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TEINL2 -inherit
I want to extract the UPPER name (eg:PRXPLO on the first line), so I do:
ps -eaf | grep lsnr | grep -v ' LISTENER ' | grep -v grep | awk -F "${ORA_LISTENER_HEADER}|${ORA_LISTENER_HEADER_UPPER}|tnslsnr " '{print $2}'
PRXPLO -inherit
TECHIMIO -inherit
TEIAC -inherit
TEIMG -inherit
PROCTM2 -inherit
TEOCTM -inherit
TEANA -inherit
PRCHIMIO -inherit
PRIACS -inherit
{print $2}
PRINL -inherit
TEINL2 -inherit
*Note: In this command, "${ORA_LISTENER_HEADER}|${ORA_LISTENER_HEADER_UPPER}|tnslsnr " will be equivalent to "tnslsnr "
Obviously, the line containing " {print $2} " should not exists, but I can not find where it comes from. I know that I could simply exclude it via a grep, but I would prefer to understand what I do wrong.
Can someone help me on this issue?
Thanks all.
为了缓解问题,只需使用一个awk调用:
ps -eaf | awk '/lsnr/ && !/ LISTENER / {print $(NF-1)}'
Yes, you have to exclude it via grep. awk is a separate process and it is shown in the list of processes you grep by running the whole chain.
ps -eaf | grep lsnr | grep -v ' LISTENER ' | grep -v grep | grep -v awk | awk -F "${ORA_LISTENER_HEADER}|${ORA_LISTENER_HEADER_UPPER}|tnslsnr " '{print $2}'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.