Problem Find Just Program Running: ps -Alf | grep (on SGI OS) leads to many grep v options - SGI

This is a discussion on Problem Find Just Program Running: ps -Alf | grep (on SGI OS) leads to many grep v options - SGI ; Hello, The problem is, I want to find only instances of my_prog that are running. I start the executable my_prog by typing ./my_prog at the command line. I have a 2nd program that does the parsing of ps output. The ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Problem Find Just Program Running: ps -Alf | grep (on SGI OS) leads to many grep v options

  1. Problem Find Just Program Running: ps -Alf | grep (on SGI OS) leads to many grep v options

    Hello,

    The problem is, I want to find only instances of my_prog that
    are running. I start the executable my_prog by typing ./my_prog at the
    command line. I have a 2nd program that does the parsing of ps output.

    The test program is:

    /* CODE */

    int main ()
    { /* MODIFICATIONS THAT SOLVE THE PROBLEM GO HERE */
    char ps_command [100] = "ps -Alf | grep \\.\\/my_prog > tmp_file";

    system (ps_command);
    }

    /* END */

    The above program is partially wrong because it parses out things
    such as:

    (1) The above system call itself because of the ./my_prog in the
    grep, and
    (2) vi /usr/clusardi/my_prog_data/FILE

    These two things have nothing to do with my_prog running. The grep
    option "v" (IE: appending -v vi -v grep) will lead, I am afraid, to an
    ever increasing string size.

    What must I do? Will using the ps command with different options
    help?

    An example my_prog could be

    /* my_prog code */

    int main ()
    {
    while (1);
    }

    /* end my_prog */


    Christopher Lusardi


  2. Re: Problem Find Just Program Running: ps -Alf | grep (on SGI OS)leads to many grep v options

    clusardi2k@aol.com wrote:
    > Hello,
    >
    > The problem is, I want to find only instances of my_prog that
    > are running. I start the executable my_prog by typing ./my_prog at the
    > command line. I have a 2nd program that does the parsing of ps output.


    I suggest that you use the -o switch and explicitly specify the fields
    you want listed and have "comm" or "args" be the field first. Then
    anchor you grep RE to the beginning (i.e. leading $) and add a match on
    a trailing space to it.

    -- ced

    >
    > The test program is:
    >
    > /* CODE */
    >
    > int main ()
    > { /* MODIFICATIONS THAT SOLVE THE PROBLEM GO HERE */
    > char ps_command [100] = "ps -Alf | grep \\.\\/my_prog > tmp_file";
    >
    > system (ps_command);
    > }
    >
    > /* END */
    >
    > The above program is partially wrong because it parses out things
    > such as:
    >
    > (1) The above system call itself because of the ./my_prog in the
    > grep, and
    > (2) vi /usr/clusardi/my_prog_data/FILE
    >
    > These two things have nothing to do with my_prog running. The grep
    > option "v" (IE: appending -v vi -v grep) will lead, I am afraid, to an
    > ever increasing string size.
    >
    > What must I do? Will using the ps command with different options
    > help?
    >
    > An example my_prog could be
    >
    > /* my_prog code */
    >
    > int main ()
    > {
    > while (1);
    > }
    >
    > /* end my_prog */
    >
    >
    > Christopher Lusardi
    >



    --
    Chuck Dillon
    Senior Software Engineer
    NimbleGen Systems Inc.

  3. Re: Problem Find Just Program Running: ps -Alf | grep (on SGI OS) leads to many grep v options

    In article <1114000908.744643.83330@f14g2000cwb.googlegroups.c om>,
    clusardi2k@aol.com wrote:

    : The problem is, I want to find only instances of my_prog that
    : are running. I start the executable my_prog by typing ./my_prog at the
    : command line. I have a 2nd program that does the parsing of ps output.

    I suspect you're going about this the wrong way. What exactly are you trying to
    achieve?


    Cheers - Tony 'Nicoya' Mantler

    --
    Tony 'Nicoya' Mantler -- Master of Code-fu -- nicoya@ubb.ca
    -- http://nicoya.feline.pp.se/ -- http://www.ubb.ca/ --

  4. Re: Problem Find Just Program Running: ps -Alf | grep (on SGI OS) leads to many grep v options

    In article , Chuck Dillon wrote:
    > clusardi2k@aol.com wrote:
    >> Hello,
    >>
    >> The problem is, I want to find only instances of my_prog that
    >> are running. I start the executable my_prog by typing ./my_prog at the
    >> command line. I have a 2nd program that does the parsing of ps output.

    >
    > I suggest that you use the -o switch and explicitly specify the fields
    > you want listed and have "comm" or "args" be the field first. Then
    > anchor you grep RE to the beginning (i.e. leading $) and add a match on
    > a trailing space to it.
    >
    > -- ced
    >
    >>
    >> The test program is:
    >>
    >> /* CODE */
    >>
    >> int main ()
    >> { /* MODIFICATIONS THAT SOLVE THE PROBLEM GO HERE */
    >> char ps_command [100] = "ps -Alf | grep \\.\\/my_prog > tmp_file";
    >>
    >> system (ps_command);
    >> }
    >>
    >> /* END */
    >>
    >> The above program is partially wrong because it parses out things
    >> such as:
    >>
    >> (1) The above system call itself because of the ./my_prog in the
    >> grep, and
    >> (2) vi /usr/clusardi/my_prog_data/FILE
    >>
    >> These two things have nothing to do with my_prog running. The grep
    >> option "v" (IE: appending -v vi -v grep) will lead, I am afraid, to an
    >> ever increasing string size.
    >>
    >> What must I do? Will using the ps command with different options
    >> help?
    >>
    >> An example my_prog could be
    >>
    >> /* my_prog code */
    >>
    >> int main ()
    >> {
    >> while (1);
    >> }
    >>
    >> /* end my_prog */
    >>


    Additionally, you can try 'ps -e'...

    Kevin
    --
    Unix Guy Consulting, LLC
    Unix and Linux Automation, Shell, Perl and CGI scripting
    http://www.unix-guy.com

+ Reply to Thread