<?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: Shell program query in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735819#M836982</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;To kill the parent shell of your script within your script, instead of $$, use $PPID. &lt;BR /&gt;&lt;BR /&gt;kill -9 $PPID&lt;BR /&gt;&lt;BR /&gt;This works because while $$ is the PID of your current shell (i.e. killing this PID kills your script), $PPID is the PID of your parent shell (i.e. killing this PID kills the shell from which your script is launched).&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
    <pubDate>Sun, 02 Jun 2002 08:58:08 GMT</pubDate>
    <dc:creator>Steven Sim Kok Leong</dc:creator>
    <dc:date>2002-06-02T08:58:08Z</dc:date>
    <item>
      <title>Shell program query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735815#M836978</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Can any one tell me how to kill the same shell?. I have written a script, it looks like this &lt;BR /&gt;&lt;BR /&gt;pids=`ps |grep sh | awk '{print $1}'&lt;BR /&gt;echo $pids&lt;BR /&gt;......&lt;BR /&gt;kill -9 $pids&lt;BR /&gt;&lt;BR /&gt;I ran this script in two ways on the prompt:&lt;BR /&gt;1.  $exam_script (failed to kill itself)&lt;BR /&gt;2.  $. exam_script (killed itself)&lt;BR /&gt;But in the first condition its giving a message like "Killed".  My question is why it is not able to kill the parent shell from the child shell?.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Vasu</description>
      <pubDate>Sat, 01 Jun 2002 12:44:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735815#M836978</guid>
      <dc:creator>Vasudevan MV</dc:creator>
      <dc:date>2002-06-01T12:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735816#M836979</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;try simply the command:&lt;BR /&gt;&lt;BR /&gt;kill -9 $$&lt;BR /&gt;&lt;BR /&gt;$$ will be replaced by the PID of your shell.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Allways stay on the bright side of life!&lt;BR /&gt;&lt;BR /&gt;Peter</description>
      <pubDate>Sat, 01 Jun 2002 13:46:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735816#M836979</guid>
      <dc:creator>Peter Kloetgen</dc:creator>
      <dc:date>2002-06-01T13:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735817#M836980</link>
      <description>Very important:  ps and grep will *ALWAYS* give you unwanted entries!!!  Try to avoid using grep with ps.  In your case, ps|grep sh will give you ksh bash and lots of other unrelated processes like users that have sh in their user name.&lt;BR /&gt;&lt;BR /&gt;Instead, use the -C option in ps. NOTE: this an XPG4 option, so temporarily set UNIX95 so it will work.  For your example:&lt;BR /&gt;&lt;BR /&gt;pids=$(UNIX95= ps -C sh)&lt;BR /&gt;&lt;BR /&gt;To find all sh shells:&lt;BR /&gt;&lt;BR /&gt;pids=$(UNIX95= ps -efC sh)&lt;BR /&gt;</description>
      <pubDate>Sat, 01 Jun 2002 14:39:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735817#M836980</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2002-06-01T14:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735818#M836981</link>
      <description>Peter,&lt;BR /&gt;&lt;BR /&gt;I have tried this also already, but I got the same message like "killed" but failed to parent shell.  &lt;BR /&gt;&lt;BR /&gt;Bill,&lt;BR /&gt;As you mentioned the option in your reply, it gives all the shell pids, but How do I kill a parent shell from a child shell?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Vasu&lt;BR /&gt;</description>
      <pubDate>Sun, 02 Jun 2002 07:24:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735818#M836981</guid>
      <dc:creator>Vasudevan MV</dc:creator>
      <dc:date>2002-06-02T07:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735819#M836982</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;To kill the parent shell of your script within your script, instead of $$, use $PPID. &lt;BR /&gt;&lt;BR /&gt;kill -9 $PPID&lt;BR /&gt;&lt;BR /&gt;This works because while $$ is the PID of your current shell (i.e. killing this PID kills your script), $PPID is the PID of your parent shell (i.e. killing this PID kills the shell from which your script is launched).&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Sun, 02 Jun 2002 08:58:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program-query/m-p/2735819#M836982</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-06-02T08:58:08Z</dc:date>
    </item>
  </channel>
</rss>

