<?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: Determine what called script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/determine-what-called-script/m-p/3837683#M100665</link>
    <description>As mentioned, use the variable $PPID which is the process's parent. However, don't use grep and ps -- you'll get erratic results. The reason is that the PPID might be 123 and grep will match 123 1234 4123 24123 in both PID and PPID as well as possible command line parameters. Use this:&lt;BR /&gt; &lt;BR /&gt;ps -fp $PPID&lt;BR /&gt; &lt;BR /&gt;and you'll always get the parent's details.</description>
    <pubDate>Sun, 06 Aug 2006 20:15:29 GMT</pubDate>
    <dc:creator>Bill Hassell</dc:creator>
    <dc:date>2006-08-06T20:15:29Z</dc:date>
    <item>
      <title>Determine what called script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/determine-what-called-script/m-p/3837680#M100662</link>
      <description>Is there a way to tell in a script whether it was called from the command line or by another script.  And if it was a script, which one?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Fri, 04 Aug 2006 15:55:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/determine-what-called-script/m-p/3837680#M100662</guid>
      <dc:creator>Steve Givens</dc:creator>
      <dc:date>2006-08-04T15:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Determine what called script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/determine-what-called-script/m-p/3837681#M100663</link>
      <description>The easiest way is to look at the PPID (Parent Process ID) of the script.  Then look for that PID.  That will tell you what you want to know.&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;I want to know what started an instance of gpm.&lt;BR /&gt;&lt;BR /&gt;gpm's PPID is 25067.&lt;BR /&gt;&lt;BR /&gt;user 28888 25067  0 11:12:39 pts/0     1:08 gpm&lt;BR /&gt;&lt;BR /&gt;So I look for PID 25067:&lt;BR /&gt;&lt;BR /&gt;# ps -ef |grep 25067&lt;BR /&gt;user 25067 25065  0 11:10:45 pts/0     0:00 -sh&lt;BR /&gt;user 28888 25067  0 11:12:39 pts/0     1:08 gpm&lt;BR /&gt;&lt;BR /&gt;You see that PID 25067 is a '-sh' process.  So it was started from user's shell.</description>
      <pubDate>Fri, 04 Aug 2006 16:01:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/determine-what-called-script/m-p/3837681#M100663</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2006-08-04T16:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Determine what called script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/determine-what-called-script/m-p/3837682#M100664</link>
      <description>Hi Steve:&lt;BR /&gt;&lt;BR /&gt;I don't know of any definitive way to determine this.  A 'ps' of the running process can provide clues such as the parent process; the associated terminal (if any); etc.  I'd start with :&lt;BR /&gt;&lt;BR /&gt;# UNIX95= ps -eH&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 04 Aug 2006 16:08:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/determine-what-called-script/m-p/3837682#M100664</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-04T16:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Determine what called script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/determine-what-called-script/m-p/3837683#M100665</link>
      <description>As mentioned, use the variable $PPID which is the process's parent. However, don't use grep and ps -- you'll get erratic results. The reason is that the PPID might be 123 and grep will match 123 1234 4123 24123 in both PID and PPID as well as possible command line parameters. Use this:&lt;BR /&gt; &lt;BR /&gt;ps -fp $PPID&lt;BR /&gt; &lt;BR /&gt;and you'll always get the parent's details.</description>
      <pubDate>Sun, 06 Aug 2006 20:15:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/determine-what-called-script/m-p/3837683#M100665</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-08-06T20:15:29Z</dc:date>
    </item>
  </channel>
</rss>

