<?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: Argument Checking in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807983#M779863</link>
    <description>Per the man page for ps, the -o -H -C options do not exist in ps unless the UNIX95 variable is used. As mentioned, it must always be set temporarily as it affects MANY other commands in unexpected ways. If you would to have all the UNIX95 options available when you type ps, use alias:&lt;BR /&gt; &lt;BR /&gt;alias ps='UNIX95= /usr/bin/ps'&lt;BR /&gt; &lt;BR /&gt;Now you always get the -o (etc) options. As James implied with his scri-pt, get rid of all your ps|grep scripts! grep is a terrible way to locate process names. Just try this to find all the sh processes:&lt;BR /&gt; &lt;BR /&gt;ps -ef|grep sh&lt;BR /&gt; &lt;BR /&gt;If you were to script this and kill the matching processes, you would kill (among other things):&lt;BR /&gt; &lt;BR /&gt;- unhashdaemon and sshd&lt;BR /&gt;- all processes owned by josh and sherry&lt;BR /&gt;- shells like sh ksh csh bash tcsh&lt;BR /&gt; &lt;BR /&gt;A very bad situation indeed. Always use -C to select a process by it's exact name as in:&lt;BR /&gt; &lt;BR /&gt;UNIX95= ps -fC sh&lt;BR /&gt; &lt;BR /&gt;And another nifty feature: the -o headers for the selected columns can be removed with header= as in:&lt;BR /&gt; &lt;BR /&gt;UNIX95= ps -fC sh -o pid= -o ppid= -o args&lt;BR /&gt; &lt;BR /&gt;By setting all the -o options to a null title, the entire title line disappears, saving an extra test to drop the title line.&lt;BR /&gt; &lt;BR /&gt;Another overlooked feature in ps is the standard (UNIX95 not needed) -u and -p options which find processes by username and PID respectively. So ps is full of 100% accurate selection options. No more grep for ps.</description>
    <pubDate>Mon, 19 Jun 2006 16:35:32 GMT</pubDate>
    <dc:creator>Bill Hassell</dc:creator>
    <dc:date>2006-06-19T16:35:32Z</dc:date>
    <item>
      <title>Argument Checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807979#M779859</link>
      <description>On our HP-UX 11.11i V1 systems, our staff  likes to use the -o argument to the ps command when looking for a specific process information. In HP-UX I have to set the UNIX95 variable to do this. Is there another I can use the ps command and get the same results without setting UNIX95?&lt;BR /&gt;&lt;BR /&gt;proc_jobman=$(UNIX95=l ps -u root -o pid,args|grep /opt/maestro/bin/jobman|awk 'BEGIN {ORS = " "} {print $1}')&lt;BR /&gt;if [[ -n $proc_jobman ]]&lt;BR /&gt;then&lt;BR /&gt;   #kill the jobman process&lt;BR /&gt;   echo "sending kill to jobman process $proc_jobman"&lt;BR /&gt;   kill -9 $proc_jobman&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;&lt;BR /&gt;Chuck Ciesinski</description>
      <pubDate>Mon, 19 Jun 2006 09:47:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807979#M779859</guid>
      <dc:creator>Chuck Ciesinski</dc:creator>
      <dc:date>2006-06-19T09:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Argument Checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807980#M779860</link>
      <description>Well, ps -u root -f (or -x if patched) will also show the argumentrs supplied to the command (-x will show arguments beyond 80 characters). The output is not the same but the data are there. On the other hand, by asserting the XPG4 (UNIX95= ) behavior, the output can be tailored to exactly what you want so not using the XPG4 behavior appears to be a step in the wrong direction. If you hate the syntax so much, you could always define an alias.</description>
      <pubDate>Mon, 19 Jun 2006 09:53:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807980#M779860</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-06-19T09:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Argument Checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807981#M779861</link>
      <description>I dont think so there is any other method.&lt;BR /&gt;But if its just the pid and args you are interested in then you may also use&lt;BR /&gt;ps -u root -f | awk '{print $2,$NF}' ....&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ninad</description>
      <pubDate>Mon, 19 Jun 2006 09:56:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807981#M779861</guid>
      <dc:creator>Ninad_1</dc:creator>
      <dc:date>2006-06-19T09:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Argument Checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807982#M779862</link>
      <description>&lt;!--!*#--&gt;Hi Chuck:&lt;BR /&gt;&lt;BR /&gt;First, release 11.11 is known as 11iv1.&lt;BR /&gt;&lt;BR /&gt;With HP-UX it is necessary to arm the UNIX95 (XPG4) option to be able to use the '-o' switch.&lt;BR /&gt;&lt;BR /&gt;This is in fact the best/safest/easiest way to match a process's basename to 'ps' output and be assured that you find only what you want.&lt;BR /&gt;&lt;BR /&gt;Be setting confining the setting of UNIX95 to the command line for the 'ps' you are keeping the variable set only for the commandline.  This is desirable since exporting UNIX95 into your environment may affect other commands in ways you don't want.  The 'cp' command is one command that is influenced differently by this setting.&lt;BR /&gt;&lt;BR /&gt;ALSO:&lt;BR /&gt;&lt;BR /&gt;Never kill with 'kill -9' except as a last resort. A 'kill -9' cannot be ignored or trapped and it doesn't give a process any chance to clean up shared memory segments or remove temporary files.&lt;BR /&gt;&lt;BR /&gt;Instead, use a multi-level kill, starting with a hangup; then a simple 'kill -15'; and as a last resort a 'kill -9'.&lt;BR /&gt;&lt;BR /&gt;The following script will kill a process by name in a much safer way:&lt;BR /&gt;&lt;BR /&gt;# cat .killer&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;myproc=`basename ${1}`&lt;BR /&gt;[ -z "${1}" ] &amp;amp;&amp;amp; { echo "no process specified!"; exit 1; }&lt;BR /&gt;mypid=`UNIX95= ps -C ${myproc} -o pid=`&lt;BR /&gt;if [ ! -z "${mypid}" ]; then&lt;BR /&gt;    kill -1 ${mypid} 2&amp;gt;/dev/null&lt;BR /&gt;    sleep 3&lt;BR /&gt;    kill -15 ${mypid} 2&amp;gt;/dev/null&lt;BR /&gt;    sleep 3&lt;BR /&gt;    kill -9 ${mypid} 2&amp;gt;/dev/null&lt;BR /&gt;fi&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;...Run as ./killer basename&lt;BR /&gt;&lt;BR /&gt;...where 'basename' is the name of the process you want killed.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 19 Jun 2006 10:02:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807982#M779862</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-06-19T10:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Argument Checking</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807983#M779863</link>
      <description>Per the man page for ps, the -o -H -C options do not exist in ps unless the UNIX95 variable is used. As mentioned, it must always be set temporarily as it affects MANY other commands in unexpected ways. If you would to have all the UNIX95 options available when you type ps, use alias:&lt;BR /&gt; &lt;BR /&gt;alias ps='UNIX95= /usr/bin/ps'&lt;BR /&gt; &lt;BR /&gt;Now you always get the -o (etc) options. As James implied with his scri-pt, get rid of all your ps|grep scripts! grep is a terrible way to locate process names. Just try this to find all the sh processes:&lt;BR /&gt; &lt;BR /&gt;ps -ef|grep sh&lt;BR /&gt; &lt;BR /&gt;If you were to script this and kill the matching processes, you would kill (among other things):&lt;BR /&gt; &lt;BR /&gt;- unhashdaemon and sshd&lt;BR /&gt;- all processes owned by josh and sherry&lt;BR /&gt;- shells like sh ksh csh bash tcsh&lt;BR /&gt; &lt;BR /&gt;A very bad situation indeed. Always use -C to select a process by it's exact name as in:&lt;BR /&gt; &lt;BR /&gt;UNIX95= ps -fC sh&lt;BR /&gt; &lt;BR /&gt;And another nifty feature: the -o headers for the selected columns can be removed with header= as in:&lt;BR /&gt; &lt;BR /&gt;UNIX95= ps -fC sh -o pid= -o ppid= -o args&lt;BR /&gt; &lt;BR /&gt;By setting all the -o options to a null title, the entire title line disappears, saving an extra test to drop the title line.&lt;BR /&gt; &lt;BR /&gt;Another overlooked feature in ps is the standard (UNIX95 not needed) -u and -p options which find processes by username and PID respectively. So ps is full of 100% accurate selection options. No more grep for ps.</description>
      <pubDate>Mon, 19 Jun 2006 16:35:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/argument-checking/m-p/3807983#M779863</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-06-19T16:35:32Z</dc:date>
    </item>
  </channel>
</rss>

