<?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: ps command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551936#M917620</link>
    <description>This comand will show you the number of instances of a program running on the system. &lt;BR /&gt;&lt;BR /&gt;ps -ef |grep "program name"</description>
    <pubDate>Thu, 12 Jul 2001 13:20:53 GMT</pubDate>
    <dc:creator>John Booth_1</dc:creator>
    <dc:date>2001-07-12T13:20:53Z</dc:date>
    <item>
      <title>ps command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551934#M917618</link>
      <description>Is there a function to find out the number of instances of a program running on the system?&lt;BR /&gt;&lt;BR /&gt;What system calls does the ps command use to get the process information?&lt;BR /&gt;&lt;BR /&gt;Kapil&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jul 2001 13:15:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551934#M917618</guid>
      <dc:creator>Kapil_2</dc:creator>
      <dc:date>2001-07-12T13:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: ps command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551935#M917619</link>
      <description>Hi Kapil:&lt;BR /&gt;&lt;BR /&gt;I believe 'ps' uses pstat() to obtain much of its information.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 12 Jul 2001 13:20:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551935#M917619</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-07-12T13:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: ps command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551936#M917620</link>
      <description>This comand will show you the number of instances of a program running on the system. &lt;BR /&gt;&lt;BR /&gt;ps -ef |grep "program name"</description>
      <pubDate>Thu, 12 Jul 2001 13:20:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551936#M917620</guid>
      <dc:creator>John Booth_1</dc:creator>
      <dc:date>2001-07-12T13:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: ps command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551937#M917621</link>
      <description>If you've got O'Reilly's Perl Cookbook, you'll find a useful program called psgrep.&lt;BR /&gt;&lt;BR /&gt;Robin</description>
      <pubDate>Thu, 12 Jul 2001 13:28:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551937#M917621</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-07-12T13:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: ps command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551938#M917622</link>
      <description>Hi&lt;BR /&gt;These may help:-&lt;BR /&gt;&lt;BR /&gt;ps -ef|sort    ----- output sorted&lt;BR /&gt;&lt;BR /&gt;ps -ef|grep &lt;PROG name=""&gt; |wc -l    ---- output counted&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;Paula&lt;/PROG&gt;</description>
      <pubDate>Thu, 12 Jul 2001 13:57:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551938#M917622</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2001-07-12T13:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: ps command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551939#M917623</link>
      <description>Using the command you suggested will also give the grep command. Here is my px command.&lt;BR /&gt;I removes the grep from the list. The only problem I ran into is if you are looking for processes with grep in them. &lt;BR /&gt;alias -x px='ps -aef|grep -v grep | grep '&lt;BR /&gt;I put it in my .profile and I always have it.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jul 2001 19:13:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551939#M917623</guid>
      <dc:creator>eric stewart_1</dc:creator>
      <dc:date>2001-07-12T19:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: ps command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551940#M917630</link>
      <description>Actually, there is a much simpler way to do this.  The ps man page lists a number of options that are activated when XPG4 behavior is setup.  This is done by simply defining the UNIX95 variable.  Something like this:&lt;BR /&gt;&lt;BR /&gt;UNIX95= ps -C prog-name&lt;BR /&gt;&lt;BR /&gt;This is much more efficient than grep'ing through the entire ps list and removing anything with grep. In fact it is the only way to accurately find all copies of grep.&lt;BR /&gt;&lt;BR /&gt;NOTE: Counting the 'true' instances of any program is quite difficult to do accurately. The name of a program (the -C option) comes from the basename of the file containing the program. Any user could create a program called syncer (for instance) and other than the owner's name, it would be difficult to determine just what this program might be. The full pathname of a program is shown in ps only if the program was started that way (another good reason for all root scripts to use full pathnames).&lt;BR /&gt;&lt;BR /&gt;Note also that the line: UNIX95= ps ... is not a typo. The UNIX95= is a quick way to TEMPORARILY assign the env variable UNIX95 for just the duration of the ps command. DON'T do something like:&lt;BR /&gt;&lt;BR /&gt;export UNIX95=&lt;BR /&gt;ps -C prog-name&lt;BR /&gt;&lt;BR /&gt;as many system programs and libraries will behave differently (ie, XPG4 behavior) with UNIX95 set.  XPG4 also allows process hierarchies to be seen with the -H option.</description>
      <pubDate>Fri, 13 Jul 2001 00:09:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551940#M917630</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2001-07-13T00:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: ps command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551941#M917632</link>
      <description>Hi Kapil,&lt;BR /&gt;&lt;BR /&gt;ps uses pstat_getproc() to do the major portion of its work. If I were doing it in c I think I would build up a command string and then call popen(). Something like this:&lt;BR /&gt;&lt;BR /&gt;char s_cmd[1024];&lt;BR /&gt;char *target_process = "my_process";&lt;BR /&gt;FILE *f = NULL;&lt;BR /&gt;&lt;BR /&gt;(void) sprintf(s_cmd,"ps -e | grep %s | grep -v grep",target_process);&lt;BR /&gt;f = popen(s_cmd,"r");&lt;BR /&gt;if (f != NULL)&lt;BR /&gt;  {&lt;BR /&gt;    char *p = NULL,s[512];&lt;BR /&gt;    int knt = 0;&lt;BR /&gt;&lt;BR /&gt;    p = fgets(s,sizeof(s),f);&lt;BR /&gt;    while (p != NULL)&lt;BR /&gt;      {&lt;BR /&gt;        ++knt;&lt;BR /&gt;        .....&lt;BR /&gt;        p = fgets(s,sizeof(s),f);&lt;BR /&gt;      }&lt;BR /&gt;    (void) pclose(f);&lt;BR /&gt;    (void) printf("%d instances of %s found\n",&lt;BR /&gt;           knt,target_process);&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;This should be close to what you are looking for, Clay  &lt;BR /&gt;</description>
      <pubDate>Fri, 13 Jul 2001 00:12:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551941#M917632</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-07-13T00:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: ps command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551942#M917633</link>
      <description>Hi James,&lt;BR /&gt;That is exactly what I was looking for.&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;Hi John, Paula, Eric, Bill&lt;BR /&gt;Well, actually I wanted to find it out through a program without using the system function to invoke the ps command.&lt;BR /&gt;Thanks anyway.&lt;BR /&gt;&lt;BR /&gt;Hi Robin,&lt;BR /&gt;I'll check it out.&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;Hi Clay,&lt;BR /&gt;The command pstat_getproc is what I was looking for.&lt;BR /&gt;Thanks.&lt;BR /&gt;Would the procedure that you mentioned be faster than using the pstat_getproc system call?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Just another clarification.&lt;BR /&gt;From the manual page for pstat I understand that when we want to use a shortcut i.e. to get info about a single process, the parameter index should refer to the pid of the process. But otherwise index should not refer to the pid of the process. Then what does index refer to in cases other than the shortcut?&lt;BR /&gt;&lt;BR /&gt;Kapil</description>
      <pubDate>Sat, 14 Jul 2001 14:08:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ps-command/m-p/2551942#M917633</guid>
      <dc:creator>Kapil_2</dc:creator>
      <dc:date>2001-07-14T14:08:47Z</dc:date>
    </item>
  </channel>
</rss>

