hell script for bringing down/startup listeners

[83]Hi Michael, It worked as expected. Awesome. But i...... kiran kumar
[84]Post the result of "ps -eaf | grep [t]nslsnr" in...... Michel Cadot
[85]<pre>ps -eaf | grep [t]nslsnr </pre> oracle 23...... kiran kumar
[86]I can't see in your post what is in the actual o...... Michel Cadot
[87]<pre> $ps -eaf | grep [t]nslsnr ++++++++++++++++...... kiran kumar
[88]HI Michael, I got the output what i want. <pre>...... kiran kumar
[89]Make your field separater be the space / " /" and ...... Tim Boles
[90]Hi Kiran Do not use <pre>ps -ef</pre>. Use the ...... Jan

Subject: Shell script for bringing down/startup listeners
Os info: All platforms
Message: Hi Team,
I need your help very badly.
Please find output from below command.
ps â€"ef|grep -i tnslsnr|grep â€"v grep >> list.txt
% cat list.txt
oracle 7575 15091 0 Dec 19 ? 11:09
/usr/software/oracle/product/11.2.0/bin/tnslsnr l_pvtf -inherit
oracle 14482 15091 0 Dec 19 ? 7:54
/usr/software/oracle/product/11.2.0/bin/tnslsnr l_pvt030 -inherit
oracle 10285 15091 0 Dec 19 ? 29:17
/usr/software/oracle/product/11.2.0/bin/tnslsnr l_pvth -inherit
From about output, I want output further as below. I used awk â€"F “ “
‘{print $9 $10}’ .
/usr/software/oracle/product/11.2.0/bin/tnslsnr l_pvtf
/usr/software/oracle/product/11.2.0/bin/tnslsnr l_pvt030
/usr/software/oracle/product/11.2.0/bin/tnslsnr l_pvth
if you count number of fields in this output is 11.
Field1 filed2 field3 field4 field 5.. Field11
oracle 7575 15091 0 Dec 19 ? 11:09
/usr/software/oracle/product/11.2.0/bin/tnslsnr l_pvtf -inherit
oracle 14482 15091 0 Dec 19 ? 7:54
/usr/software/oracle/product/11.2.0/bin/tnslsnr l_pvt030 -inherit
oracle 10285 15091 0 Dec 19 ? 29:17
/usr/software/oracle/product/11.2.0/bin/tnslsnr l_pvth -inherit
If this count is constant for all OS, I could use awk â€"F “ “ ‘{print $9
$10}’ so that it will give my expectation.
This command working fine in Solaris. But same command when I used in
Linux ad other OS it is not giving what I expected.
$ uname -s
Linux
$ ps -ef|grep tns|grep -v grep
Field1 Field2 Field3 .. Field10
oracle 2387 1 0 2014 ? 02:08:57
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr l_pgb018 -inherit
oracle 16111 1 0 2013 ? 00:00:15
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_PGB018_GER
-inherit
oracle 16322 1 0 2013 ? 00:00:00
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_TECHOPS -inherit
If you see above output from Linux server the total fields are 9
separated by space.
So above my command will not return what I expected. So need your help
in getting output as I expected irrespective of OS.
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr l_pgb018
etc
Highly appreciated your help.
Thanks and Regards,
KiranKumar Aluvala,
Oracle DBA,HP India,
M:- +91-8496946261


Subject: Re: Shell script for bringing down/startup listeners
Message:
I have no Unix/Linux to test it but I think this should give the result
you want:
ps -eaf | grep [t]nslsnr | sed -e 's/^.* \([^ ]*tnslsnr [^ ]*\).*$/\1/'
Regards
Michel


Subject: Re: Shell script for bringing down/startup listeners
Message: Hi Michael,
It worked as expected. Awesome. But it is ending up with one error as
below.
uname -s
Linux
ps -eaf | grep [t]nslsnr | sed -e 's/^.* \([^ ]*tnslsnr [^ ]*\).*$/\1/'
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr l_pgb018
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_PGB018_GER
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_TECHOPS
]*tnslsnr [^
$
++++++++
prd002*:/usr/software/oracle
% uname -s
SunOS
prd002*:/usr/software/oracle
% ps -eaf | grep [t]nslsnr | sed -e 's/^.* \([^ ]*tnslsnr [^
]*\).*$/\1/'
/usr/software/oracle/product/10.2.0/bin/tnslsnr l_pvt002
/usr/software/oracle/product/10.2.0/bin/tnslsnr l_pvt043
]*tnslsnr [^
/usr/software/oracle/product/11.2.0.3/bin/tnslsnr l_pbr064
/usr/software/oracle/product/10.2.0/bin/tnslsnr l_pvt044
/usr/software/oracle/product/11.2.0.3/bin/tnslsnr l_pbr097
/usr/software/oracle/product/10.2.0/bin/tnslsnr l_pvt049
prd002*:/usr/software/oracle
%


Subject: Re: Shell script for bringing down/startup listeners
Message:
Post the result of "ps -eaf | grep [t]nslsnr" including blank lines.
Please use tags as explained in the "formatting" section in the "Reply"
page above the text field.
A quick fix would be to exclude the line containing '[' using a "grep
-v".
Are you executing the command I gave on a command line or within a
script?
Regards
Michel


Subject: Re: Shell script for bringing down/startup listeners
Message:
ps -eaf | grep [t]nslsnr

oracle 2387 1 0 2014 ? 02:08:57
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr l_pgb018 -inherit
oracle 16111 1 0 2013 ? 00:00:15
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_PGB018_GER
-inherit
oracle 16322 1 0 2013 ? 00:00:00
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_TECHOPS -inherit
++++++++++++++
sh dst.sh

/usr/software/oracle/product/11.2.0/db/bin/tnslsnr l_pgb018
]*tnslsnr [^
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_PGB018_GER
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_TECHOPS
[C0426635@brqsb1valedb115 ~]$
I ran on command prompt and script both end up with that extra line.


Subject: Re: Shell script for bringing down/startup listeners
Message:
I can't see in your post what is in the actual output and what is in
the post.
Please enclose the output between +++ lines and use pre tags on this
output NOT just the command.
It is not possible the sed command returns more lines than the output
of the command line without sed.


Subject: Re: Shell script for bringing down/startup listeners
Message:
$ps -eaf | grep [t]nslsnr
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
oracle 2387 1 0 2014 ? 02:08:57 /usr/software/oracle/product/11.2.0/db/bin/tnsls
nr l_pgb018 -inherit
oracle 16111 1 0 2013 ? 00:00:15 /usr/software/oracle/product/11.2.0/db/bin/tnsl
snr L_PGB018_GER -inherit
oracle 16322 1 0 2013 ? 00:00:00 /usr/software/oracle/product/11.2.0/db/bin/tnsl
snr L_TECHOPS -inherit

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<pre $sh dst.sh
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr l_pgb018
]*tnslsnr [^
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_PGB018_GER
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_TECHOPS
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I ran your command on command prompt and script both end up with that
extra line.


Subject: Re: Shell script for bringing down/startup listeners
Message: HI Michael,
I got the output what i want.
$ps -eaf | grep [t]nslsnr | sed -e 's/^.* \([^ ]*tnslsnr [^ ]*\).*$/\1/' |grep "
/tnslsnr"|grep -v grep
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr l_pgb018
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_PGB018_GER
/usr/software/oracle/product/11.2.0/db/bin/tnslsnr L_TECHOPS



Subject: Re: Shell script for bringing down/startup listeners
Message: Make your field separater be the space / " /" and then just
print the second field adding a "/" to the beginning.
cat list.txt | awk -F " /" '{ print "/"$2 }'
Regards
Tim


Subject: Re: Shell script for bringing down/startup listeners
Message: Hi Kiran
Do not use
ps -ef

. Use the man page to look at the "o" option and only select the fields
you need. This will even allow you to remove the awk command.
Regards, Jan

Enregistrer un commentaire

0 Commentaires