FAQ
Hi All,

I want to feed my shell script with the names of currently running
databases. I thought of using ps -ef|grep [p]mon. What I got was the
following:

oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

What I wanted is get only the db name part eg. TLDEV, RMAN, DBMON,etc. I
don't want to rely on oratab file.
I was thinking of using 'cut' to cut out the last field and do some ${X##}
(variable pattern substitution) to get to the dbname bit. The trouble is
the number of fields in a ps -ef output is not consistent. As you can see
I've just restarted RMAN and now it only has 8 fields as compared to 9 for
the others.

Any suggestions? Or another way of doing it?
Using KSH on Solaris 8.

Thanks.
Ross

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Ross Collado
INET: Ross.Collado_at_techpac.com

Fat City Network Services -- 858-538-5051 http://www.fatcity.com
San Diego, California -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).

Search Discussions

  • Mark J. Bobak at Oct 28, 2002 at 2:53 am
    As is often the case, there are a million ways to do this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{ print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of currently running
    databases. I thought of using ps -ef|grep [p]mon. What I got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN, DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and do some ${X##}
    (variable pattern substitution) to get to the dbname bit. The trouble is
    the number of fields in a ps -ef output is not consistent. As you can see
    I've just restarted RMAN and now it only has 8 fields as compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Sujatha Madan at Oct 28, 2002 at 3:38 am
    Hi Ross,

    Try something like this:

    DBNAME=`ps -ef | grep pmon | awk '{db=substr($NF, 10); print db}'`

    There are several ways of doing this - what's above is just one.

    Cheers
    Sujatha

    -----Original Message-----
    Sent: Monday, 28 October 2002 12:43 PM
    To: Multiple recipients of list ORACLE-L

    Hi All,

    I want to feed my shell script with the names of currently running
    databases. I thought of using ps -ef|grep [p]mon. What I got was the
    following:

    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN, DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and do some ${X##}
    (variable pattern substitution) to get to the dbname bit. The trouble is
    the number of fields in a ps -ef output is not consistent. As you can see
    I've just restarted RMAN and now it only has 8 fields as compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------

    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Sujatha Madan
    INET: Sujatha.Madan_at_cmc.optus.net.au

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------

    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Ross Collado at Oct 28, 2002 at 3:53 am
    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to parse the last field!
    However, a slight problem in the ps -ef output. If I do what you have
    suggested on my 'ps -ef' output below, I would only get RMAN as it is the
    only one in field #8. All the rest are in field #9. All I need now is
    figure out how to cut the last field then pipe it to your awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross
    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Alex at Oct 28, 2002 at 3:58 am
    ps -ef|grep [p]mon | awk '{ print $7 }' | sed 's/ora_pmon_//'
    On Sun, 27 Oct 2002, Ross Collado wrote:


    Hi All,

    I want to feed my shell script with the names of currently running
    databases. I thought of using ps -ef|grep [p]mon. What I got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN, DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and do some ${X##}
    (variable pattern substitution) to get to the dbname bit. The trouble is
    the number of fields in a ps -ef output is not consistent. As you can see
    I've just restarted RMAN and now it only has 8 fields as compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Alex
    INET: axs_at_m-net.arbornet.org

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Ross Collado at Oct 28, 2002 at 4:33 am
    Browsing through my Sed and Awk book following up on Mark's lead, I came up
    with this:

    ps -ef|grep pmon|grep -v grep|awk '{ print $NF }'|awk -F_ '{ print $3 }'

    TLDEV

    TLQA

    TLQAVAR

    DBMON

    RMAN

    PRDINF

    TLDVVAR

    That'll do fine !

    Thanks again.
    Ross
    -----Original Message-----
    From: Ross Collado
    Sent: Monday, 28 October 2002 14:50
    To: 'ORACLE-L_at_fatcity.com'
    Subject: RE: Unix Q: Substring-ing an output.


    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to parse
    the last field! However, a slight problem in the ps -ef
    output. If I do what you have suggested on my 'ps -ef'
    output below, I would only get RMAN as it is the only one in
    field #8. All the rest are in field #9. All I need now is
    figure out how to cut the last field then pipe it to your awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross


    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the '_'
    and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web
    hosting services

    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Mark J. Bobak at Oct 28, 2002 at 4:48 am
    Hmm...good point. You know, I use this technique in various places. I
    never noticed that bug before, cause it will only appear if the database
    has been up less than 1 day. Guess it's time to do a bit of script
    auditing.

    Ok, try this instead:
    ps -ef|grep pmon|grep -v grep|cut -c49- |awk -F_ '{ 'print $3 }'

    I replaced the first awk w/ cut. the -c option says to cut that output
    from position 49 to the end of the line. You may have to adjust the
    value from 49 to something else.

    That ought to work for you.

    -Mark
    On Sun, 2002-10-27 at 22:53, Ross Collado wrote:
    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to parse the last field!
    However, a slight problem in the ps -ef output. If I do what you have
    suggested on my 'ps -ef' output below, I would only get RMAN as it is the
    only one in field #8. All the rest are in field #9. All I need now is
    figure out how to cut the last field then pipe it to your awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross


    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Henry Poras at Oct 28, 2002 at 4:43 pm
    Quick thought. What about just setting awk -F_ to awk -Fpmon_ ???

    Henry

    -----Original Message-----
    Bobak
    Sent: Sunday, October 27, 2002 11:49 PM
    To: Multiple recipients of list ORACLE-L

    Hmm...good point. You know, I use this technique in various places. I
    never noticed that bug before, cause it will only appear if the database
    has been up less than 1 day. Guess it's time to do a bit of script
    auditing.

    Ok, try this instead:
    ps -ef|grep pmon|grep -v grep|cut -c49- |awk -F_ '{ 'print $3 }'

    I replaced the first awk w/ cut. the -c option says to cut that output
    from position 49 to the end of the line. You may have to adjust the
    value from 49 to something else.

    That ought to work for you.

    -Mark
    On Sun, 2002-10-27 at 22:53, Ross Collado wrote:
    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to parse the last field!
    However, a slight problem in the ps -ef output. If I do what you have
    suggested on my 'ps -ef' output below, I would only get RMAN as it is the
    only one in field #8. All the rest are in field #9. All I need now is
    figure out how to cut the last field then pipe it to your awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross


    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Henry Poras
    INET: hporas_at_etal.URI.EDU

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Ross Collado at Oct 28, 2002 at 11:24 pm
    Very clever! But unfortunately, -F accepts only 1 character. I tried that
    though...

    Ross
    -----Original Message-----
    From: Henry Poras
    Sent: Tuesday, 29 October 2002 3:43
    To: Multiple recipients of list ORACLE-L
    Subject: RE: Unix Q: Substring-ing an output.


    Quick thought. What about just setting awk -F_ to awk -Fpmon_ ???

    Henry

    -----Original Message-----
    Bobak
    Sent: Sunday, October 27, 2002 11:49 PM
    To: Multiple recipients of list ORACLE-L


    Hmm...good point. You know, I use this technique in various
    places. I
    never noticed that bug before, cause it will only appear if
    the database
    has been up less than 1 day. Guess it's time to do a bit of script
    auditing.

    Ok, try this instead:
    ps -ef|grep pmon|grep -v grep|cut -c49- |awk -F_ '{ 'print $3 }'

    I replaced the first awk w/ cut. the -c option says to cut
    that output
    from position 49 to the end of the line. You may have to adjust the
    value from 49 to something else.

    That ought to work for you.

    -Mark
    On Sun, 2002-10-27 at 22:53, Ross Collado wrote:
    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to parse the last field!
    However, a slight problem in the ps -ef output. If I do
    what you have
    suggested on my 'ps -ef' output below, I would only get
    RMAN as it is the
    only one in field #8. All the rest are in field #9. All I
    need now is
    figure out how to cut the last field then pipe it to your
    awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross


    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do
    this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the
    '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of
    currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is
    to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051
    http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Henry Poras
    INET: hporas_at_etal.URI.EDU

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Mark Richard at Oct 28, 2002 at 11:58 pm
    I could be mistaken, but isn't all this discussion about the "awk '{ print
    $8 }'" problem unwarranted...

    The very next portion of the command is an awk using a field seperator of
    underscore. It doesn't care if it receives the entire line from ps. Just
    remove that component and the problem is fixed. From what I can tell:

    ps -ef | grep smon | grep -v grep | awk -F_ '{ print $3 }'

    Is one way of many to get your result.

    Ross Collado

    chpac.com> cc:
    Sent by: Subject: RE: Unix Q: Substring-ing an output.
    root_at_fatcity.com

    29/10/2002 10:24
    Please respond
    to ORACLE-L

    Very clever! But unfortunately, -F accepts only 1 character. I tried that
    though...

    Ross
    -----Original Message-----
    From: Henry Poras
    Sent: Tuesday, 29 October 2002 3:43
    To: Multiple recipients of list ORACLE-L
    Subject: RE: Unix Q: Substring-ing an output.


    Quick thought. What about just setting awk -F_ to awk -Fpmon_ ???

    Henry

    -----Original Message-----
    Bobak
    Sent: Sunday, October 27, 2002 11:49 PM
    To: Multiple recipients of list ORACLE-L


    Hmm...good point. You know, I use this technique in various
    places. I
    never noticed that bug before, cause it will only appear if
    the database
    has been up less than 1 day. Guess it's time to do a bit of script
    auditing.

    Ok, try this instead:
    ps -ef|grep pmon|grep -v grep|cut -c49- |awk -F_ '{ 'print $3 }'

    I replaced the first awk w/ cut. the -c option says to cut
    that output
    from position 49 to the end of the line. You may have to adjust the
    value from 49 to something else.

    That ought to work for you.

    -Mark
    On Sun, 2002-10-27 at 22:53, Ross Collado wrote:
    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to parse the last field!
    However, a slight problem in the ps -ef output. If I do
    what you have
    suggested on my 'ps -ef' output below, I would only get
    RMAN as it is the
    only one in field #8. All the rest are in field #9. All I
    need now is
    figure out how to cut the last field then pipe it to your
    awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross


    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do
    this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the
    '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of
    currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is
    to use it
    well."
    -- Rene
    Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051
    http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene
    Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Henry Poras
    INET: hporas_at_etal.URI.EDU

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Privileged/Confidential information may be contained in this message.
    If you are not the addressee indicated in this message
    (or responsible for delivery of the message to such person),
    you may not copy or deliver this message to anyone.
    In such case, you should destroy this message and kindly notify the sender
    by reply e-mail or by telephone on (61 3) 9612-6999.
    Please advise immediately if you or your employer does not consent to
    Internet e-mail for messages of this kind.
    Opinions, conclusions and other information in this message
    that do not relate to the official business of
    Transurban City Link Ltd
    shall be understood as neither given nor endorsed by it.
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark Richard
    INET: mrichard_at_transurban.com.au

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Trevor.Williams_at_rac.com.au at Oct 29, 2002 at 12:03 am
    Ross

    ps -ef | grep ora_smon | grep -v grep | awk 'FS="smon_" {print $2}'
    works fine for me on HP-UX

    trevor

    -----Original Message-----
    Sent: Tuesday, 29 October 2002 7:24 am
    To: Multiple recipients of list ORACLE-L

    Very clever! But unfortunately, -F accepts only 1 character. I tried that
    though...

    Ross
    -----Original Message-----
    From: Henry Poras
    Sent: Tuesday, 29 October 2002 3:43
    To: Multiple recipients of list ORACLE-L
    Subject: RE: Unix Q: Substring-ing an output.


    Quick thought. What about just setting awk -F_ to awk -Fpmon_ ???

    Henry

    -----Original Message-----
    Bobak
    Sent: Sunday, October 27, 2002 11:49 PM
    To: Multiple recipients of list ORACLE-L


    Hmm...good point. You know, I use this technique in various
    places. I
    never noticed that bug before, cause it will only appear if
    the database
    has been up less than 1 day. Guess it's time to do a bit of script
    auditing.

    Ok, try this instead:
    ps -ef|grep pmon|grep -v grep|cut -c49- |awk -F_ '{ 'print $3 }'

    I replaced the first awk w/ cut. the -c option says to cut
    that output
    from position 49 to the end of the line. You may have to adjust the
    value from 49 to something else.

    That ought to work for you.

    -Mark
    On Sun, 2002-10-27 at 22:53, Ross Collado wrote:
    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to parse the last field!
    However, a slight problem in the ps -ef output. If I do
    what you have
    suggested on my 'ps -ef' output below, I would only get
    RMAN as it is the
    only one in field #8. All the rest are in field #9. All I
    need now is
    figure out how to cut the last field then pipe it to your
    awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross


    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do
    this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the
    '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of
    currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is
    to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051
    http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Henry Poras
    INET: hporas_at_etal.URI.EDU

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    Disclaimer.

    This e-mail is private and confidential. If you are not the intended
    recipient, please advise us by return e-mail immediately, and delete
    the e-mail and any attachments without using or disclosing the
    contents in any way. The views expressed in this e-mail are those
    of the author, and do not represent those of this company unless
    this is clearly indicated.

    You should scan this e-mail and any attachments for viruses.

    This company accepts no liability for any direct or indirect
    damage or loss resulting from the use of any attachments to this e-mail.

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author:
    INET: Trevor.Williams_at_rac.com.au

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • John Carlson at Oct 29, 2002 at 12:03 am
    Try :
    ps -ef|grep pmon|grep -v grep | awk '{ print $NF }' |awk -F_ '{ print $3 }'

    The 'NF' is number of fields and will give you the last field regardless of the number. I use this technique all the time. If you don't want the last field, you can use: awk '{ i=NF-1; print $i }' where -1 is the next to last field.

    HTH,

    John Carlson
    www.cj.com
    Ross.Collado_at_techpac.com 10/28/02 03:24PM >>>
    Very clever! But unfortunately, -F accepts only 1 character. I tried that
    though...

    Ross
    -----Original Message-----
    From: Henry Poras
    Sent: Tuesday, 29 October 2002 3:43
    To: Multiple recipients of list ORACLE-L
    Subject: RE: Unix Q: Substring-ing an output.


    Quick thought. What about just setting awk -F_ to awk -Fpmon_ ???

    Henry

    -----Original Message-----
    Bobak
    Sent: Sunday, October 27, 2002 11:49 PM
    To: Multiple recipients of list ORACLE-L


    Hmm...good point. You know, I use this technique in various
    places. I
    never noticed that bug before, cause it will only appear if
    the database
    has been up less than 1 day. Guess it's time to do a bit of script
    auditing.

    Ok, try this instead:
    ps -ef|grep pmon|grep -v grep|cut -c49- |awk -F_ '{ 'print $3 }'

    I replaced the first awk w/ cut. the -c option says to cut
    that output
    from position 49 to the end of the line. You may have to adjust the
    value from 49 to something else.

    That ought to work for you.

    -Mark
    On Sun, 2002-10-27 at 22:53, Ross Collado wrote:
    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to parse the last field!
    However, a slight problem in the ps -ef output. If I do
    what you have
    suggested on my 'ps -ef' output below, I would only get
    RMAN as it is the
    only one in field #8. All the rest are in field #9. All I
    need now is
    figure out how to cut the last field then pipe it to your
    awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross


    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do
    this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the
    '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of
    currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is
    to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051
    http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Henry Poras
    INET: hporas_at_etal.URI.EDU

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in 1 0 Oct 25 ? 0:01 o
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: John Carlson
    INET: jcarlson_at_CJ.COM

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Stephen Lee at Oct 29, 2002 at 12:28 am
    awk/nawk/gawk has gotten way too much credit on this one.
    We really should give sed a little credit too.

    ps -eo args | sed -n 's/\(^ora_smon_\)\(.*\)/\2/p'

    -----Original Message-----

    Very clever! But unfortunately, -F accepts only 1 character. I tried that
    though...

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Stephen Lee
    INET: slee_at_dollar.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------

    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Sujatha Madan at Oct 29, 2002 at 12:43 am
    Why bother with all that anyway! ... Just use $NF. I still like my way the
    best (not tooting my own trumpet or anything;)). For those of you who
    missed it:

    ps -ef | grep pmon | awk '{db=substr($NF, 10); print db}'

    Cheers
    Sujatha

    -----Original Message-----
    Sent: Tuesday, 29 October 2002 10:59 AM
    To: Multiple recipients of list ORACLE-L

    I could be mistaken, but isn't all this discussion about the "awk '{ print
    $8 }'" problem unwarranted...

    The very next portion of the command is an awk using a field seperator of
    underscore. It doesn't care if it receives the entire line from ps. Just
    remove that component and the problem is fixed. From what I can tell:

    ps -ef | grep smon | grep -v grep | awk -F_ '{ print $3 }'

    Is one way of many to get your result.



    Ross Collado

    chpac.com> cc:

    Sent by: Subject: RE: Unix Q:
    Substring-ing an output.
    root_at_fatcity.com

    29/10/2002 10:24

    Please respond

    to ORACLE-L

    Very clever! But unfortunately, -F accepts only 1 character. I tried that
    though...

    Ross
    -----Original Message-----
    From: Henry Poras
    Sent: Tuesday, 29 October 2002 3:43
    To: Multiple recipients of list ORACLE-L
    Subject: RE: Unix Q: Substring-ing an output.


    Quick thought. What about just setting awk -F_ to awk -Fpmon_ ???

    Henry

    -----Original Message-----
    Bobak
    Sent: Sunday, October 27, 2002 11:49 PM
    To: Multiple recipients of list ORACLE-L


    Hmm...good point. You know, I use this technique in various
    places. I
    never noticed that bug before, cause it will only appear if
    the database
    has been up less than 1 day. Guess it's time to do a bit of script
    auditing.

    Ok, try this instead:
    ps -ef|grep pmon|grep -v grep|cut -c49- |awk -F_ '{ 'print $3 }'

    I replaced the first awk w/ cut. the -c option says to cut
    that output
    from position 49 to the end of the line. You may have to adjust the
    value from 49 to something else.

    That ought to work for you.

    -Mark
    On Sun, 2002-10-27 at 22:53, Ross Collado wrote:
    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to parse the last field!
    However, a slight problem in the ps -ef output. If I do
    what you have
    suggested on my 'ps -ef' output below, I would only get
    RMAN as it is the
    only one in field #8. All the rest are in field #9. All I
    need now is
    figure out how to cut the last field then pipe it to your
    awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross


    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do
    this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the
    '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of
    currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is
    to use it
    well."
    -- Rene
    Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051
    http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene
    Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Henry Poras
    INET: hporas_at_etal.URI.EDU

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    >>>>
    Privileged/Confidential information may be contained in this message.
    If you are not the addressee indicated in this message
    (or responsible for delivery of the message to such person),
    you may not copy or deliver this message to anyone.
    In such case, you should destroy this message and kindly notify the sender
    by reply e-mail or by telephone on (61 3) 9612-6999.
    Please advise immediately if you or your employer does not consent to
    Internet e-mail for messages of this kind.
    Opinions, conclusions and other information in this message
    that do not relate to the official business of
    Transurban City Link Ltd
    shall be understood as neither given nor endorsed by it.
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    >>>>

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark Richard
    INET: mrichard_at_transurban.com.au

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Sujatha Madan
    INET: Sujatha.Madan_at_cmc.optus.net.au

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Ross Collado at Oct 29, 2002 at 12:53 am
    Yes, you're right. Sometimes the most obvious solution is the first one
    missed! I really shouldn't care about the last field as the output line I
    expect will always have 2 '_' . Thanks Mark.

    Ross
    -----Original Message-----
    From: Mark Richard
    Sent: Tuesday, 29 October 2002 10:59
    To: Multiple recipients of list ORACLE-L
    Subject: RE: Unix Q: Substring-ing an output.


    I could be mistaken, but isn't all this discussion about the
    "awk '{ print
    $8 }'" problem unwarranted...

    The very next portion of the command is an awk using a field
    seperator of
    underscore. It doesn't care if it receives the entire line
    from ps. Just
    remove that component and the problem is fixed. From what I can tell:

    ps -ef | grep smon | grep -v grep | awk -F_ '{ print $3 }'

    Is one way of many to get your result.





    Ross Collado
    recipients of list ORACLE-L
    chpac.com> cc:

    Sent by: Subject: RE:
    Unix Q: Substring-ing an output.
    root_at_fatcity.com





    29/10/2002 10:24

    Please respond

    to ORACLE-L









    Very clever! But unfortunately, -F accepts only 1 character.
    I tried that
    though...

    Ross

    -----Original Message-----
    From: Henry Poras
    Sent: Tuesday, 29 October 2002 3:43
    To: Multiple recipients of list ORACLE-L
    Subject: RE: Unix Q: Substring-ing an output.


    Quick thought. What about just setting awk -F_ to awk -Fpmon_ ???

    Henry

    -----Original Message-----
    Bobak
    Sent: Sunday, October 27, 2002 11:49 PM
    To: Multiple recipients of list ORACLE-L


    Hmm...good point. You know, I use this technique in various
    places. I
    never noticed that bug before, cause it will only appear if
    the database
    has been up less than 1 day. Guess it's time to do a bit of script
    auditing.

    Ok, try this instead:
    ps -ef|grep pmon|grep -v grep|cut -c49- |awk -F_ '{ 'print $3 }'

    I replaced the first awk w/ cut. the -c option says to cut
    that output
    from position 49 to the end of the line. You may have to adjust the
    value from 49 to something else.

    That ought to work for you.

    -Mark
    On Sun, 2002-10-27 at 22:53, Ross Collado wrote:
    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to
    parse the last
    field!
    However, a slight problem in the ps -ef output. If I do
    what you have
    suggested on my 'ps -ef' output below, I would only get
    RMAN as it is the
    only one in field #8. All the rest are in field #9. All I
    need now is
    figure out how to cut the last field then pipe it to your
    awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross


    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do
    this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the
    '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of
    currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07
    ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00
    ora_pmon_TLDVVAR
    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is
    to use it
    well."
    -- Rene
    Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051
    http://www.fatcity.com
    San Diego, California -- Mailing list and web
    hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of
    'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed
    from). You may
    also send the HELP command for other information (like
    subscribing).
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene
    Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Henry Poras
    INET: hporas_at_etal.URI.EDU

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).



    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>
    Privileged/Confidential information may be contained in
    this message.
    If you are not the addressee indicated in this message
    (or responsible for delivery of the message to such person),
    you may not copy or deliver this message to anyone.
    In such case, you should destroy this message and kindly
    notify the sender
    by reply e-mail or by telephone on (61 3) 9612-6999.
    Please advise immediately if you or your employer does not
    consent to
    Internet e-mail for messages of this kind.
    Opinions, conclusions and other information in this message
    that do not relate to the official business of
    Transurban City Link Ltd
    shall be understood as neither given nor endorsed by it.
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark Richard
    INET: mrichard_at_transurban.com.au

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
  • Mark J. Bobak at Oct 29, 2002 at 3:13 am
    Heh, good point Mark. Sometines, I make a simple problem
    complicated...;-)
    On Mon, 2002-10-28 at 18:58, Mark Richard wrote:
    I could be mistaken, but isn't all this discussion about the "awk '{ print
    $8 }'" problem unwarranted...

    The very next portion of the command is an awk using a field seperator of
    underscore. It doesn't care if it receives the entire line from ps. Just
    remove that component and the problem is fixed. From what I can tell:

    ps -ef | grep smon | grep -v grep | awk -F_ '{ print $3 }'

    Is one way of many to get your result.




    Ross Collado

    chpac.com> cc:
    Sent by: Subject: RE: Unix Q: Substring-ing an output.
    root_at_fatcity.com


    29/10/2002 10:24
    Please respond
    to ORACLE-L






    Very clever! But unfortunately, -F accepts only 1 character. I tried that
    though...

    Ross

    -----Original Message-----
    From: Henry Poras
    Sent: Tuesday, 29 October 2002 3:43
    To: Multiple recipients of list ORACLE-L
    Subject: RE: Unix Q: Substring-ing an output.


    Quick thought. What about just setting awk -F_ to awk -Fpmon_ ???

    Henry

    -----Original Message-----
    Bobak
    Sent: Sunday, October 27, 2002 11:49 PM
    To: Multiple recipients of list ORACLE-L


    Hmm...good point. You know, I use this technique in various
    places. I
    never noticed that bug before, cause it will only appear if
    the database
    has been up less than 1 day. Guess it's time to do a bit of script
    auditing.

    Ok, try this instead:
    ps -ef|grep pmon|grep -v grep|cut -c49- |awk -F_ '{ 'print $3 }'

    I replaced the first awk w/ cut. the -c option says to cut
    that output
    from position 49 to the end of the line. You may have to adjust the
    value from 49 to something else.

    That ought to work for you.

    -Mark
    On Sun, 2002-10-27 at 22:53, Ross Collado wrote:
    Thanks Mark.

    Yes that helps, in a way. I could use good ol' awk to parse the last field!
    However, a slight problem in the ps -ef output. If I do
    what you have
    suggested on my 'ps -ef' output below, I would only get
    RMAN as it is the
    only one in field #8. All the rest are in field #9. All I
    need now is
    figure out how to cut the last field then pipe it to your
    awk command.
    Ok I'm getting somewhere!

    Rgds,
    Ross


    -----Original Message-----
    From: Mark J. Bobak
    Sent: Monday, 28 October 2002 13:54
    To: Multiple recipients of list ORACLE-L
    Subject: Re: Unix Q: Substring-ing an output.


    As is often the case, there are a million ways to do
    this. Given the
    output listed, I'd do something like:

    ps -ef|grep pmon|grep -v grep|awk '{ print $8 }'|awk -F_ '{
    print $3 }'

    ps -ef -- get the programs that are running
    grep pmon -- get only those lines that have 'pmon' in them
    grep -v grep -- drop out the line that has 'grep pmon'
    awk '{ print $8 }' -- get the eighth column, the program name
    awk -F_ '{ print $3 }' -- parse the program name on the
    '_' and return
    the third field, the database name.

    Hope that helps,

    -Mark
    On Sun, 2002-10-27 at 20:43, Ross Collado wrote:

    Hi All,

    I want to feed my shell script with the names of
    currently running
    databases. I thought of using ps -ef|grep [p]mon. What I
    got was the
    following:
    oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV
    oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA
    oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR
    oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON
    oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN
    oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF
    oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR

    What I wanted is get only the db name part eg. TLDEV, RMAN,
    DBMON,etc. I
    don't want to rely on oratab file.
    I was thinking of using 'cut' to cut out the last field and
    do some ${X##}
    (variable pattern substitution) to get to the dbname bit.
    The trouble is
    the number of fields in a ps -ef output is not consistent.
    As you can see
    I've just restarted RMAN and now it only has 8 fields as
    compared to 9 for
    the others.

    Any suggestions? Or another way of doing it?
    Using KSH on Solaris 8.

    Thanks.
    Ross
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is
    to use it
    well."
    -- Rene
    Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051
    http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene
    Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Henry Poras
    INET: hporas_at_etal.URI.EDU

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Ross Collado
    INET: Ross.Collado_at_techpac.com

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).



    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Privileged/Confidential information may be contained in this message.
    If you are not the addressee indicated in this message
    (or responsible for delivery of the message to such person),
    you may not copy or deliver this message to anyone.
    In such case, you should destroy this message and kindly notify the sender
    by reply e-mail or by telephone on (61 3) 9612-6999.
    Please advise immediately if you or your employer does not consent to
    Internet e-mail for messages of this kind.
    Opinions, conclusions and other information in this message
    that do not relate to the official business of
    Transurban City Link Ltd
    shall be understood as neither given nor endorsed by it.
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    --
    --
    Mark J. Bobak
    Oracle DBA
    mark_at_bobak.net
    "It is not enough to have a good mind. The main thing is to use it
    well."
    -- Rene Descartes
    --
    Please see the official ORACLE-L FAQ: http://www.orafaq.com
    --
    Author: Mark J. Bobak
    INET: mark_at_bobak.net

    Fat City Network Services -- 858-538-5051 http://www.fatcity.com
    San Diego, California -- Mailing list and web hosting services
    ---------------------------------------------------------------------
    To REMOVE yourself from this mailing list, send an E-Mail message
    to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
    the message BODY, include a line containing: UNSUB ORACLE-L
    (or the name of mailing list you want to be removed from). You may
    also send the HELP command for other information (like subscribing).

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouporacle-l @
categoriesoracle
postedOct 28, '02 at 1:43a
activeOct 29, '02 at 3:13a
posts16
users9
websiteoracle.com

People

Translate

site design / logo © 2022 Grokbase