<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: grep artifacts in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472590#M849566</link>
    <description>Hi,&lt;BR /&gt;I tried this on my UNIX box and here is what I got:&lt;BR /&gt;&lt;BR /&gt;# UNIX95= ps -fC sh&lt;BR /&gt;ps: Not a recognized flag: C&lt;BR /&gt;Usage: ps [-ANaedfklm] [-n namelist] [-F Format] [-o specifier[=header],...]&lt;BR /&gt;                [-p proclist][-G|-g grouplist] [-t termlist] [-U|-u userlist] [-c classlist]&lt;BR /&gt;Usage: ps [aceglnsuvwxU] [t tty] [processnumber]&lt;BR /&gt;&lt;BR /&gt;Similar problems were encountered with the other commands mentioned.  Do I have something that is not configured correctly ?&lt;BR /&gt;&lt;BR /&gt;Gil&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 27 Jan 2005 10:47:32 GMT</pubDate>
    <dc:creator>Gilbert Standen_1</dc:creator>
    <dc:date>2005-01-27T10:47:32Z</dc:date>
    <item>
      <title>grep artifacts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472583#M849559</link>
      <description>Hi, if do "ps -ef | grep pmon" sometimes I just get &lt;BR /&gt;  oracle  962572       1   0   Jan 11      -  2:13 ora_pmon_ATCQ2&lt;BR /&gt;&lt;BR /&gt;but sometimes I get pmon, and grep also catches "itself" i.e. same command as above returns:  &lt;BR /&gt;oracle  962572       1   0   Jan 11      -  2:13 ora_pmon_ATCQ2&lt;BR /&gt;  oracle 1495276 2539608   0 08:55:20  pts/1  0:00 grep pmon&lt;BR /&gt;&lt;BR /&gt;However, if I type "ps -ef | grep pmon | grep ATCQ2" it always returns just the proc of interest, and grep never detects itself as above.&lt;BR /&gt;&lt;BR /&gt;My question is, why should this be the case ?  I use ps -ef often for program control steps such as running parallel commands in their own shell, and the feature of grep was something found by trial and error, but I wondered if there is a reason for it.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Jan 2005 09:01:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472583#M849559</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2005-01-27T09:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: grep artifacts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472584#M849560</link>
      <description>Depending on the CPU click tic, you can and usually do get the grep itself also.&lt;BR /&gt;&lt;BR /&gt;It would be safer to do "ps -e | grep pmon"  instead of "ps -ef | grep pmon".  This will eliminate the grep.  &lt;BR /&gt;&lt;BR /&gt;You could also do "ps -ef | grep pmon | grep -v grep", however, this adds yet another unnecessary system call.</description>
      <pubDate>Thu, 27 Jan 2005 09:05:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472584#M849560</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2005-01-27T09:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: grep artifacts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472585#M849561</link>
      <description>Sometimes your just lucky enough to catch the grep process, sometime not.&lt;BR /&gt;&lt;BR /&gt;If you are doing this within a script the way to solve it is to add an extra 'grep -v grep' to your command.  That way the grep process itself will be ignored.&lt;BR /&gt;&lt;BR /&gt;So your command would be:&lt;BR /&gt;&lt;BR /&gt;ps -ef | grep process | grep -v grep</description>
      <pubDate>Thu, 27 Jan 2005 09:06:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472585#M849561</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2005-01-27T09:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: grep artifacts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472586#M849562</link>
      <description>hi Gilbert &lt;BR /&gt;&lt;BR /&gt;the correct way is to use the &lt;BR /&gt;ps -ef|grep XXX |grep -v grep&lt;BR /&gt;regards &lt;BR /&gt;Henk</description>
      <pubDate>Thu, 27 Jan 2005 09:08:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472586#M849562</guid>
      <dc:creator>Henk Geurts</dc:creator>
      <dc:date>2005-01-27T09:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: grep artifacts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472587#M849563</link>
      <description>The first grep in your command takes its input from ps -ef and will therefore output two lines.&lt;BR /&gt;&lt;BR /&gt;The second grep takes it input from the first one: i.e. the two lines described above. As only one of these will have ATCQ2 in it, this is the only line you will see.&lt;BR /&gt;&lt;BR /&gt;You could achieve the same result by:&lt;BR /&gt;&lt;BR /&gt;ps -ef|grep pmon|grep -v grep&lt;BR /&gt;&lt;BR /&gt;Mark Syder (like the drink but spelt different)</description>
      <pubDate>Thu, 27 Jan 2005 09:09:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472587#M849563</guid>
      <dc:creator>MarkSyder</dc:creator>
      <dc:date>2005-01-27T09:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: grep artifacts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472588#M849564</link>
      <description>Actually, grep should be avoided when filtering the ps command. ps has many, many options to give you an EXACT match of what you are looking for and never 'catches' itself so you never have to grep -v grep.&lt;BR /&gt; &lt;BR /&gt;To find an exact command name:&lt;BR /&gt; UNIX95= ps -fC mycommand&lt;BR /&gt; &lt;BR /&gt;For example, compare the following:&lt;BR /&gt; ps -ef | grep sh&lt;BR /&gt; UNIX95= ps -fC sh&lt;BR /&gt; &lt;BR /&gt;You'll notice that the second form ALWAYS matches the process name (sh) while the first method matches sh, ksh, bash, unhashdaemon, sshd and so on. The -C option is disabled by default but turned on whenever UNIX95 is defined. You can define it with just UNIX95= or set it to any value such as UNIX95=1. The ps program doesn't care. DO NOT export UNIX95 on a separate line!! This is a pervasive variable that when it is set, will change the behavior of several libraries (and thus applications) as well as certain programs. In the case of ps, just include it on the same line (as shown above) and it disappears once the command is finished.&lt;BR /&gt; &lt;BR /&gt;There are dozens of options to select proceses, and two additional UNIX95 values: -H and -o. Try this:&lt;BR /&gt; &lt;BR /&gt; UNIX95= ps -eH&lt;BR /&gt; &lt;BR /&gt;which shows all the parent/child relationships. Add -f to verify the PID/PPID relationships:&lt;BR /&gt; &lt;BR /&gt; UNIX95= ps -efH &lt;BR /&gt; &lt;BR /&gt;And because -f has extra items, you can use -o to customize your own ps output:&lt;BR /&gt; &lt;BR /&gt; UNIX95= ps -eH -o pid,ppid,ruser,args&lt;BR /&gt; &lt;BR /&gt;You can even customize the headings:&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; UNIX95= ps -eH -o pid=ProcNumber -o ppid="MY parent" -o ruser="Real User" -o args="Command Line"&lt;BR /&gt; &lt;BR /&gt;The -o option is very sueful for scripting.</description>
      <pubDate>Thu, 27 Jan 2005 09:31:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472588#M849564</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-01-27T09:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: grep artifacts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472589#M849565</link>
      <description>As always, Bill has trumped us all!&lt;BR /&gt;&lt;BR /&gt;Gilbert, give that man 11 points!&lt;BR /&gt;&lt;BR /&gt;Mark</description>
      <pubDate>Thu, 27 Jan 2005 09:50:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472589#M849565</guid>
      <dc:creator>MarkSyder</dc:creator>
      <dc:date>2005-01-27T09:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: grep artifacts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472590#M849566</link>
      <description>Hi,&lt;BR /&gt;I tried this on my UNIX box and here is what I got:&lt;BR /&gt;&lt;BR /&gt;# UNIX95= ps -fC sh&lt;BR /&gt;ps: Not a recognized flag: C&lt;BR /&gt;Usage: ps [-ANaedfklm] [-n namelist] [-F Format] [-o specifier[=header],...]&lt;BR /&gt;                [-p proclist][-G|-g grouplist] [-t termlist] [-U|-u userlist] [-c classlist]&lt;BR /&gt;Usage: ps [aceglnsuvwxU] [t tty] [processnumber]&lt;BR /&gt;&lt;BR /&gt;Similar problems were encountered with the other commands mentioned.  Do I have something that is not configured correctly ?&lt;BR /&gt;&lt;BR /&gt;Gil&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Jan 2005 10:47:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472590#M849566</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2005-01-27T10:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: grep artifacts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472591#M849567</link>
      <description>What version of HP-UX are you running?  The UNIX95 stuff should work.</description>
      <pubDate>Thu, 27 Jan 2005 10:52:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472591#M849567</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2005-01-27T10:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: grep artifacts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472592#M849568</link>
      <description>I hope you're not using csh...&lt;BR /&gt;The error message you're seeing is due to ps not seeing the UNIX95 flag, so the shell you are using is not POSIX standard (ie, not ksh, bash, sh for HP-UX, etc). What do these commands show?&lt;BR /&gt; &lt;BR /&gt;ps&lt;BR /&gt;echo $SHELL&lt;BR /&gt; &lt;BR /&gt;And I am assuming you're running HP-UX later than 9.0..(uname -r)</description>
      <pubDate>Thu, 27 Jan 2005 13:03:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-artifacts/m-p/3472592#M849568</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-01-27T13:03:48Z</dc:date>
    </item>
  </channel>
</rss>

