<?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: how to get process ID by using process name or arguments in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008226#M425942</link>
    <description>Hi again,&lt;BR /&gt;thinking about what you asked, it seems you may be looking at some sort of process tree ?&lt;BR /&gt;&lt;BR /&gt;If so, please see earlier thread:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1001424" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1001424&lt;/A&gt;</description>
    <pubDate>Thu, 12 Oct 2006 07:35:14 GMT</pubDate>
    <dc:creator>Peter Godron</dc:creator>
    <dc:date>2006-10-12T07:35:14Z</dc:date>
    <item>
      <title>how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008223#M425939</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I am using grep command with ps -ef command to get process id of my required matching process names. But since grep is also listed in this output list i am not able to get exact list, in other words i am not able to avoid grep commands entry in output.&lt;BR /&gt;&lt;BR /&gt;what is the best way to get process ID of required know process names?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;Madhava</description>
      <pubDate>Thu, 12 Oct 2006 07:21:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008223#M425939</guid>
      <dc:creator>madhavabk</dc:creator>
      <dc:date>2006-10-12T07:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008224#M425940</link>
      <description>Hi,&lt;BR /&gt;how about filtering out the grep ?&lt;BR /&gt;ps -ef | grep -v grep</description>
      <pubDate>Thu, 12 Oct 2006 07:25:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008224#M425940</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-10-12T07:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008225#M425941</link>
      <description>&lt;!--!*#--&gt;Along the same lines, we use a script in /usr/local/bin:&lt;BR /&gt;&lt;BR /&gt;##########################################################################&lt;BR /&gt;#  psg   -   Process Search&lt;BR /&gt;#            Substitute for "ps -ef|grep" command string.&lt;BR /&gt;##########################################################################&lt;BR /&gt;case $# in&lt;BR /&gt;   0) echo "Error: Argument Expected";&lt;BR /&gt;       exit;&lt;BR /&gt;       ;;&lt;BR /&gt;   1) ps -ef | grep $1 | grep -v "grep"&lt;BR /&gt;       ;;&lt;BR /&gt;   *) echo "Error: Only 1 Argument Allowed";&lt;BR /&gt;       exit;&lt;BR /&gt;       ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 12 Oct 2006 07:29:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008225#M425941</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-10-12T07:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008226#M425942</link>
      <description>Hi again,&lt;BR /&gt;thinking about what you asked, it seems you may be looking at some sort of process tree ?&lt;BR /&gt;&lt;BR /&gt;If so, please see earlier thread:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1001424" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1001424&lt;/A&gt;</description>
      <pubDate>Thu, 12 Oct 2006 07:35:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008226#M425942</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-10-12T07:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008227#M425943</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Using 'grep' to match a process name is fraught with problems!  Do this, instead:&lt;BR /&gt;&lt;BR /&gt;# UNIX95= ps -C cron -o pid=&lt;BR /&gt;&lt;BR /&gt;This will find a process whose basename is 'cron' (exactly!) and return one line representing its pid.&lt;BR /&gt;&lt;BR /&gt;There is a space after 'UNIX95=' but NO semicolon.  This arms the UNIX95 (XPG4) *only* for the duration of the commandline.  The equal sign after the '-o pid' suppresses the header line written by 'ps'.  See the manpages for 'ps' for more options and information.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 12 Oct 2006 07:43:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008227#M425943</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-10-12T07:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008228#M425944</link>
      <description>Hi Madhava,&lt;BR /&gt;&lt;BR /&gt;The "right" way to filter ps output is to use  the '-C &lt;CMDLIST&gt;' XPG4 option rather than grep:&lt;BR /&gt;&lt;BR /&gt;# UNIX95=1 ps -C myproc -o pid=&lt;BR /&gt;&lt;BR /&gt;PCS&lt;/CMDLIST&gt;</description>
      <pubDate>Thu, 12 Oct 2006 07:46:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008228#M425944</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-10-12T07:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008229#M425945</link>
      <description>As pointed out, grep is a very poor tool for ps information. ps has all the tools you need but you do have to spend time with the man page. The UNIX95 variable enables special features but it must be on the same line as ps so it does not affect other commands or libraries.&lt;BR /&gt; &lt;BR /&gt;Note that the -C option is an EXACT match for the process name, no matter how the process was started (/fullpath/procname ./procname, etc) which eliminates mistakes like grep'ing for sh to find the sh shell (and finds instead, ksh, bash, csh, unhashdaemon plus a bunch of user logins and commandline arguments with "sh" somewhere in the string.&lt;BR /&gt; &lt;BR /&gt;Note also that your script should always test for 3 possibilities: no match, one match and more than one match. If the program is never supposed to be run multiple times, your script can report the error. Also useful with the UNIX95 variable is the ability to customize exactly which columns you want and to remove the header line:&lt;BR /&gt; &lt;BR /&gt;MYPROC=myprogram&lt;BR /&gt;MYPID=$(UNIX95= ps -C $MYPROC -o pid=)&lt;BR /&gt;COUNT=$(echo "$MYPID")&lt;BR /&gt;if [ $COUNT -eq 0 ] # not running&lt;BR /&gt;then&lt;BR /&gt;echo "$MYPROC not found"&lt;BR /&gt;elif [ $COUNT -eq 1 ] # run one copy&lt;BR /&gt;then&lt;BR /&gt;echo "$MYPROC is PID $MYPID"&lt;BR /&gt;else&lt;BR /&gt;echo "$MYPROC running more than once: $MYPID"&lt;BR /&gt;fi</description>
      <pubDate>Thu, 12 Oct 2006 10:06:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008229#M425945</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-10-12T10:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008230#M425946</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;there are some glitches in Bill's solution (sorry) - it is not enough to do just that last 'echo':&lt;BR /&gt;&amp;gt;&amp;gt;&lt;BR /&gt;MYPROC=myprogram&lt;BR /&gt;MYPID=$(UNIX95= ps -C $MYPROC -o pid=)&lt;BR /&gt;COUNT=$(echo "$MYPID") &lt;BR /&gt;&amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt;Better feed all information into an array and deal with this, e.g.:&lt;BR /&gt;MYPROC=myprogram&lt;BR /&gt;set -A MYPIDs=$(UNIX95= ps -C $MYPROC -o pid=)&lt;BR /&gt;case ${#MYPIDs} in&lt;BR /&gt;0) print $myprogram is NOT running ;;&lt;BR /&gt;1) print $myprogram is running with pid=$MYPIDs ;;&lt;BR /&gt;*) print ${#MYPIDs} instances of $myprogram are running with pids ${MYPIDs[*]} ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 13 Oct 2006 12:00:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008230#M425946</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-10-13T12:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008231#M425947</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Another way to get the number of processes with the same name running is to pipe the output from 'ps' to 'wc':&lt;BR /&gt;&lt;BR /&gt;PROC=myprogram&lt;BR /&gt;COUNT=$(UNIX95=1 ps -C ${PROC} -o pid= | wc -w)&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Fri, 13 Oct 2006 12:38:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008231#M425947</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-10-13T12:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008232#M425948</link>
      <description>Thanks Peter. The line in my example:&lt;BR /&gt; &lt;BR /&gt;COUNT=$(echo "$MYPID")&lt;BR /&gt; &lt;BR /&gt;should be:&lt;BR /&gt; &lt;BR /&gt;COUNT=$(echo "$MYPID" | wc -w)&lt;BR /&gt; &lt;BR /&gt;but Peter and spex simplified it even further.</description>
      <pubDate>Fri, 13 Oct 2006 22:43:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008232#M425948</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-10-13T22:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008233#M425949</link>
      <description>Hi,&lt;BR /&gt;can you please update this thread.&lt;BR /&gt;IS this problem resoved, if so please read &lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt; , otherwise please add your comments.</description>
      <pubDate>Mon, 16 Oct 2006 03:31:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008233#M425949</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-10-16T03:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to get process ID by using process name or arguments</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008234#M425950</link>
      <description>Thanks a lot for your valuable discussion and ways shown to me.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;madhava&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Oct 2006 06:06:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-get-process-id-by-using-process-name-or-arguments/m-p/5008234#M425950</guid>
      <dc:creator>madhavabk</dc:creator>
      <dc:date>2006-10-16T06:06:27Z</dc:date>
    </item>
  </channel>
</rss>

