<?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: Script for capturing pid of particular process in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774540#M722392</link>
    <description>Hi, try this:&lt;BR /&gt;&lt;BR /&gt;PID=`ps -ef | grep $PROCNAME | grep -v grep | awk '{print $2}'`&lt;BR /&gt;echo $PID&lt;BR /&gt;&lt;BR /&gt;Greetings,&lt;BR /&gt;Ceesjan</description>
    <pubDate>Mon, 29 Jul 2002 11:08:54 GMT</pubDate>
    <dc:creator>Ceesjan van Hattum</dc:creator>
    <dc:date>2002-07-29T11:08:54Z</dc:date>
    <item>
      <title>Script for capturing pid of particular process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774538#M722390</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I want to capture ONLY the process id of a particular process and store it in a variable.&lt;BR /&gt;&lt;BR /&gt;Example, if the process id of the process "aaa" is 5643, the variable should store 5643.&lt;BR /&gt;&lt;BR /&gt;How would you do this?</description>
      <pubDate>Mon, 29 Jul 2002 11:00:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774538#M722390</guid>
      <dc:creator>Vincent Farrugia</dc:creator>
      <dc:date>2002-07-29T11:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing pid of particular process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774539#M722391</link>
      <description>Hi Vincent,&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;PID=$( ps -ef |grep "aaa" | grep -v grep| sed 's/\ \{1,\}/#/g'| cut -d"#" -f3)&lt;BR /&gt;echo $PID&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Justo.&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Jul 2002 11:04:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774539#M722391</guid>
      <dc:creator>Justo Exposito</dc:creator>
      <dc:date>2002-07-29T11:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing pid of particular process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774540#M722392</link>
      <description>Hi, try this:&lt;BR /&gt;&lt;BR /&gt;PID=`ps -ef | grep $PROCNAME | grep -v grep | awk '{print $2}'`&lt;BR /&gt;echo $PID&lt;BR /&gt;&lt;BR /&gt;Greetings,&lt;BR /&gt;Ceesjan</description>
      <pubDate>Mon, 29 Jul 2002 11:08:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774540#M722392</guid>
      <dc:creator>Ceesjan van Hattum</dc:creator>
      <dc:date>2002-07-29T11:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing pid of particular process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774541#M722393</link>
      <description>or this -&lt;BR /&gt;&lt;BR /&gt;PID=$(ps -ef|grep thingtogrepfor | grep -v grep|cut -c10-14&lt;BR /&gt;&lt;BR /&gt;So many ways to skin that cat (as we say in the UK).</description>
      <pubDate>Mon, 29 Jul 2002 11:18:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774541#M722393</guid>
      <dc:creator>Nick Wickens</dc:creator>
      <dc:date>2002-07-29T11:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing pid of particular process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774542#M722394</link>
      <description>hi,&lt;BR /&gt;try this.&lt;BR /&gt;&lt;BR /&gt;pid=`ps -ef|grep "process name"|awk '{print $2}'`&lt;BR /&gt;&lt;BR /&gt;regds</description>
      <pubDate>Mon, 29 Jul 2002 11:32:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774542#M722394</guid>
      <dc:creator>V. V. Ravi Kumar_1</dc:creator>
      <dc:date>2002-07-29T11:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing pid of particular process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774543#M722395</link>
      <description>Thank you.</description>
      <pubDate>Mon, 29 Jul 2002 12:03:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774543#M722395</guid>
      <dc:creator>Vincent Farrugia</dc:creator>
      <dc:date>2002-07-29T12:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing pid of particular process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774544#M722396</link>
      <description>Oops. ps -ef | grep -v grep | grep &lt;FOR_SOMETHING&gt; is VERY unreliable. The problem is that grep doesn't know that you specifically want just the process name, and not the path or the arguments or even the user ID. Try this:&lt;BR /&gt;&lt;BR /&gt;ps -ef | grep -v grep | grep sh&lt;BR /&gt;&lt;BR /&gt;(to look for all the sh programs (but it finds ksh and csh and bash and users with the name cash and shenn, etc&lt;BR /&gt;&lt;BR /&gt;Use this instead:&lt;BR /&gt;&lt;BR /&gt;PIDVAR=$(UNIX95= ps -C MyProcessName | tail -1 | grep -v PID | awk '{print $1}')&lt;BR /&gt;&lt;BR /&gt;where MyProcessName is the name of your selected process. This script will return the last match (in case there are two or more processes) and PIDVAR will be null if the process is not running. By using the XPG4 option -C, you are asking ps to do the searching for you and it will always match the basename of the process you are looking for.&lt;BR /&gt;&lt;BR /&gt;In the above example, here is what you need:&lt;BR /&gt;&lt;BR /&gt;UNIX95= ps -fC sh&lt;BR /&gt;&lt;BR /&gt;and now you see only the sh (and the login shells -sh).&lt;/FOR_SOMETHING&gt;</description>
      <pubDate>Mon, 29 Jul 2002 13:52:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774544#M722396</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2002-07-29T13:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing pid of particular process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774545#M722397</link>
      <description>...and if you add '-o "" ' to Bill's example, you can save the "grep -v PID", as then there will be no header line...&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Jul 2002 20:21:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774545#M722397</guid>
      <dc:creator>Wodisch_1</dc:creator>
      <dc:date>2002-07-29T20:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Script for capturing pid of particular process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774546#M722398</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Var=`ps -ef | grep "aaa" | grep -v grep | awk '{print $2}'`&lt;BR /&gt;&lt;BR /&gt;echo $var&lt;BR /&gt;&lt;BR /&gt;Hope this will helps you.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Anand Hotchandani</description>
      <pubDate>Wed, 31 Jul 2002 06:51:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-capturing-pid-of-particular-process/m-p/2774546#M722398</guid>
      <dc:creator>Anand Hotchandani</dc:creator>
      <dc:date>2002-07-31T06:51:41Z</dc:date>
    </item>
  </channel>
</rss>

