<?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: PID with pipe command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415176#M861297</link>
    <description>Unless the "cmd" is really a shell script, you cannot, it's a timing issue.  Your best bet is to change the print $$ to a ps -ef |grep cmd|grep -v grep|tr -s " " |cut -d" " -f3&amp;gt;pdi_file to extract the PID from the ps listing.&lt;BR /&gt;&lt;BR /&gt;mark</description>
    <pubDate>Thu, 04 Nov 2004 12:30:18 GMT</pubDate>
    <dc:creator>Mark Greene_1</dc:creator>
    <dc:date>2004-11-04T12:30:18Z</dc:date>
    <item>
      <title>PID with pipe command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415175#M861296</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;We are running a command and piping the output to 'tee'&lt;BR /&gt;&lt;BR /&gt;cmd | tee -a sample.log &amp;amp;&lt;BR /&gt;print "$!" &amp;gt; pid_file&lt;BR /&gt;&lt;BR /&gt;Since we are using the pipe, the PPID is getting stored in the pid_file.&lt;BR /&gt;&lt;BR /&gt;Could anyone tell us how to get the PID in the pid_file.&lt;BR /&gt;&lt;BR /&gt;The PID stored in the pid_file will be later used for killing the 'cmd' using a &lt;BR /&gt;'stop script'.&lt;BR /&gt;&lt;BR /&gt;Could anyone tell how we can get this functionality?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Siva</description>
      <pubDate>Thu, 04 Nov 2004 12:16:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415175#M861296</guid>
      <dc:creator>Siva_13</dc:creator>
      <dc:date>2004-11-04T12:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: PID with pipe command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415176#M861297</link>
      <description>Unless the "cmd" is really a shell script, you cannot, it's a timing issue.  Your best bet is to change the print $$ to a ps -ef |grep cmd|grep -v grep|tr -s " " |cut -d" " -f3&amp;gt;pdi_file to extract the PID from the ps listing.&lt;BR /&gt;&lt;BR /&gt;mark</description>
      <pubDate>Thu, 04 Nov 2004 12:30:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415176#M861297</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2004-11-04T12:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: PID with pipe command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415177#M861298</link>
      <description>&lt;BR /&gt;$ perl -e 'sleep 1000; print "done\n"' | tee -a x.x &amp;amp;&lt;BR /&gt;[1]     15219&lt;BR /&gt;$ print $!&lt;BR /&gt;15219&lt;BR /&gt;$ ps -f&lt;BR /&gt;     UID   PID  PPID  C    STIME TTY       TIME COMMAND&lt;BR /&gt;    root 15219  4146  0 07:29:04 pts/0     0:00 tee -a x.x&lt;BR /&gt;    root 15220 15219  0 07:29:04 pts/0     0:00 perl -e sleep 1000; print "done\n"&lt;BR /&gt;    root 15221  4146  1 07:29:17 pts/0     0:00 ps -f&lt;BR /&gt;    root  4146  4138  0  Nov  2  pts/0     0:00 -sh&lt;BR /&gt;&lt;BR /&gt;$ ps -f | awk -v pid=$!  '{ if ($3==pid){print $2}}'&lt;BR /&gt;15220&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Nov 2004 12:42:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415177#M861298</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-11-04T12:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: PID with pipe command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415178#M861299</link>
      <description>You can do it using perl :&lt;BR /&gt;&lt;BR /&gt;perl -e 'if (!($pid=fork())) { exec("sleep 30") } print "$pid\n";' | read childPID&lt;BR /&gt;&lt;BR /&gt;this will return pid of subprocess in childPID env var. Note that this is really basic code, and you may need to enhance fork management, redirect STDIN and STDOUT for complete separation...&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Nov 2004 12:44:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415178#M861299</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-11-04T12:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: PID with pipe command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415179#M861300</link>
      <description>I forgot the proof / sample (I tested and it worked :)&lt;BR /&gt;&lt;BR /&gt;#perl -e 'if (!($pid=fork())) { exec("sleep 30") } print "$pid\n";' | read childPID&lt;BR /&gt;#echo $childPID&lt;BR /&gt;27507&lt;BR /&gt;#ps&lt;BR /&gt;   PID TTY       TIME COMMAND&lt;BR /&gt; 27094 pts/tb    0:00 sh&lt;BR /&gt; 27507 pts/tb    0:00 sleep&lt;BR /&gt; 27093 pts/tb    0:00 telnetd&lt;BR /&gt; 27508 pts/tb    0:00 ps&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Nov 2004 12:47:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pid-with-pipe-command/m-p/3415179#M861300</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-11-04T12:47:19Z</dc:date>
    </item>
  </channel>
</rss>

